PHP:第五章——字符串转换与比较
<?php
header("Content-Type:text/html;charset=utf-8");
//字符串的转换与比较
//1.ord——返回首字符的ASCLL;chr——根据ASCLL返回对应的字符串
//例:
/*$str="中";
echo ord($str[0]),ord($str[1]),ord($str[2]);//输出:228184173
echo chr(228),chr(184),chr(173);//输出:中*/ //2.字符串的比较strcmp和strcasecmp;二进制安全字符比较。
//例:
/*$str1="Zhong";
$str2="zG";
echo strcmp($str1,$str2);//输出:-1
echo strcasecmp($str1,$str2);//输出:1*/ //3.strncmp和strncasecmp比较开头指定数量的字符。
/*$str1="zhongguo";
$str2="Zhong";
echo strncmp($str1,$str2,5);//输出:1
echo strncasecmp($str1,$str2,5);//输出:0*/ //4.strtolower和strtoupper大小写转换。
/*$str="ZhongGuo";
echo strtolower($str);//输出:zhongguo
echo strtoupper($str);//输出:ZHONGGUO */ //5.ucfirst和lcfirst首字母大小写转换
//例:
/*$str1="zhong";
echo ucfirst($str1);//输出:Zhong
$str2="ZHONG";
echo lcfirst($str2);//输出:zHONG */ //6.ucwords——将字符串中的每个单词的首字母转换为大写。
$str="welcome to you";
echo ucwords($str);//输出:Welcome To You
?>
PHP:第五章——字符串转换与比较的更多相关文章
- PHP:第五章——字符串过滤函数
<?php header("Content-Type:text/html;charset=utf-8"); //字符串过滤函数: //1.n12br 在所有新行之前插入Htm ...
- PHP:第五章——字符串的分割与替换
<?php header("Content-Type:text/html;charset=utf-8"); //字符串的截取与分割 //1.字符串截取类函数 //1)trim ...
- PHP:第五章——字符串的概念
<?php header("Content-Type:text/html;charset=utf-8"); //字符串概念: //1.单引号.//里面的变量不会被解释 //例 ...
- PHP:第五章——字符串编码函数
<?php header("Content-Type:text/html;charset=utf-8"); //1.base64_encode和base64_decode.6 ...
- PHP:第五章——字符串与数组及其他函数
<?php header("Content-Type:text/html;charset=utf-8"); //1.str_split——将字符串转换为数组. /*$str= ...
- PHP:第五章——字符串加密及校验函数
<?php header("Content-Type:text/html;charset=utf-8"); //1.md5——计算字符中的散列值 //对一段信息(Messag ...
- PHP:第五章——字符串的统计及查找
<?php header("Content-Type:text/html;charset=utf-8"); /*字符串的统计与查找*/ //1.获取字符串的长度 //1)st ...
- PHP:第五章——字符串输出函数
<?php header("Content-Type:text/html;charset=utf-8"); /*字符串输出函数*/ //1.echo 输出一个或多个字符 // ...
- 《程序员代码面试指南》第五章 字符串问题 去掉字符串中连续出现k 个0 的子串
题目 去掉字符串中连续出现k 个0 的子串 java代码 package com.lizhouwei.chapter5; /** * @Description: 去掉字符串中连续出现k 个0 的子串 ...
随机推荐
- Mercurial
Contributing Changes http://nginx.org/en/docs/contributing_changes.html Mercurial is used to store s ...
- QQ 空间过滤器 for V8
最近 QQ空间升级到 V8 版本,做了很大的调整, 我也做了升级,由于时间关系,功能暂时只有 模块过滤,其他过滤请等待后续更新,谢谢大家的支持! 刚刚上线,不知道你们能否看到 https://chro ...
- Gunicorn独角兽
1. 关于Gunicorn Gunicorn是一个开源的Python WSGI HTTP服务器,移植于Ruby的Unicorn项目的采用pre-fork模式的服务器.Gunicorn服务器可与各种We ...
- Django自带的加密算法及加密模块
Django 内置的User类提供了用户密码的存储.验证.修改等功能,可以很方便你的给用户提供密码服务. 默认的Ddjango使用pbkdf2_sha256方式来存储和管理用的密码,当然是可以自定义的 ...
- android 错误收集
2. is not translated in Eclipse > Preference > Android > Lint Error Checking的Correctness: M ...
- 【Python】获取翻页之后的各页面中的属性值。
如何获取翻页之后的页面中的html标签中的属性值? # coding=utf-8 from selenium import webdriver if __name__=="__main__& ...
- blockchain 区块链的开发,基于python或node js
现在很多人用node js做区块链的开发,因为点对点并发是区块链中的难点技术之一,而node js天然的对并发支持比较好,因此比较有优势. http://ecomunsing.com/build-yo ...
- PAT 1143 Lowest Common Ancestor[难][BST性质]
1143 Lowest Common Ancestor(30 分) The lowest common ancestor (LCA) of two nodes U and V in a tree is ...
- CCF地铁修建
问题描述 A市有n个交通枢纽,其中1号和n号非常重要,为了加强运输能力,A市决定在1号到n号枢纽间修建一条地铁. 地铁由很多段隧道组成,每段隧道连接两个交通枢纽.经过勘探,有m段隧道作为候选,两个交通 ...
- 怎么测试一个web登录页面
在以前的面试和同事面试交流的过程中,有多次被问到:“给你一个登录页面,上面有2个textbox,一个提交按钮,你将怎么测试”?或问,请针对这个页面设计30个以上的test case. 此题的考察目的: ...