CH5---php从入门到精通
2016-12-19 00:19
274 查看
<?php header("Content-type:text/html;charset=utf8"); echo "<br/>-------------------------<br/>"; echo "fruit\rpear\napple\tbanana";//linux和widows有区别的; echo "<br/>-----------自动转义字符;--------------<br/>"; $str = "select * from tb_book where bookname='PHP从入门到精通'"; echo $str."<br/>"; $a = addslashes($str); echo $a."<br/>"; $b = stripslashes($a); echo $b; echo "<br/>-----------对指定字符串转义-这个用法仅限于开始结束都包含里面?-------------<br/>"; $a = "编程体验网"; echo $a; echo "<br/>"; $b = addcslashes($a,"编程体验网"); echo $b; echo "<br/>"; $c = stripcslashes($b); echo $c; echo "<br/>-------------------------<br/>"; echo strlen("编程:www.bcty365.com"); echo "<br/>------------substr-------------<br/>"; echo substr("She is a girl",0); echo "<br/>"; echo substr("She is a girl",4,14); echo "<br/>"; echo substr("She is a girl",-4,4);//从-4向后截取4位; echo "<br/>"; echo substr("She is a girl",0,-4);//从0 到 -4位置的截取 echo "<br/>"; echo "<br/>----------strcmp按照字节比较字符串大小---------------<br/>"; $str1 = "明日编程词典"; $str2 = "明日编程词典"; $str3 = "mrsoft"; $str4 = "MRSOFT"; echo strcmp($str1,$str2); echo strcmp($str3,$str4); echo strcasecmp($str3,$str4);//不用区分大小写; echo "<br/>---------strnatcmp按照字符串中数字大小比较;----------------<br/>"; $str1 = "str2.jpg"; $str2 = "str10.jpg"; $str3 = "mrsoft1"; $str4 = "MRSOFT2"; echo strcmp($str1,$str2); echo strcmp($str3,$str4); echo strnatcmp($str1,$str2); echo strnatcmp($str3,$str4); echo "<br/>-----------strncmp在指定位置比较大小;--------------<br/>"; $str1 = "I like PHP!"; $str2 = "i an fine !"; echo strncmp($str1,$str2,2); echo "<br/>----------strstr---------------<br/>"; $str = "ioewio.ew.jpg"; echo strstr($str,'.'); echo "<br/>"; echo strchr($str,'.'); echo "<br/>--------substr_count字符串中某字符串出现的次数;-----------------<br/>"; $str = "明日编程词典词"; echo substr_count($str,"词"); echo "<br/>----------str_ireplace(search, replace, subject)---------------<br/>"; $contents = "白领女子公寓,温馨街南行200米,交通便利,亲情化专人管理,您的理想选择!"; $str="女子公寓"; echo str_replace($str,"<font color='#FF0000'>".$str."</font>",$contents); echo "<br/>----------substr_replace---书中gb的编码一个汉字占2个字符,这3个------------<br/>"; //header("Content-type:text/html;charset=gb2312"); $str = "用今日的辛勤工作,换明日的双倍回报!"; $replace = "百倍"; echo strlen($replace);//书中gb的编码一个汉字占2个字符,这3个; echo substr_replace($str, $replace,39,6); echo "<br/>-----------number_format--------------<br/>"; $num = 1868.954; echo number_format($num); echo "<br/>"; echo number_format($num,2);//1,868.95 echo "<br/>"; $num2 = 11886655.760055; echo number_format($num2,2,'*',',');//11,886,655*76 //*小数点位置, ','为分割位; echo "<br/>"; echo number_format($num2,2,'.',',');//11,886,655.76 echo "<br/>"; echo number_format($num2,2,'.','.');//11.886.655.76 echo "<br/>---------trim----p96练习题1------------<br/>"; $str="&& 明日编程词典 &&"; echo $str."<br/>"; echo trim($str,"&& &&")."kk"; echo "<br/>-------------------------<br/>"; $str = "\r\r(:@_@ 创图书编辑伟业 展软件开发雄风 @_@:) "; echo trim($str)."find space"; echo "<br/>"; echo trim($str,"\r\r(::)")."find space";//空格没去,左右两边的:)都去了; echo "<br/>-----------p96练习题2--------------<br/>"; $_POST['IDcard'] = "321323198902123336"; if((strlen($_POST['IDcard'])<>15)&&(strlen($_POST['IDcard'])<>18)){ //检测用户身份证号的长度是否正确 echo "<script>alert('用户身份证号标准长度为15位或18位才合法!');</script>"; }else{ echo "用户信息输入合法!"; } echo "<br/>----------p96练习题3---------------<br/>"; $text="白领女子公寓,温馨街南行200米,交通便利,亲情化专人管理,您的理想选择!"; $content="女子"; echo str_ireplace($content,"<font color='red'><strong>".$content."</strong></font>",$text); echo "<br/>-----------p96练习题4---explode--------------<br/>"; $content = "北京,上海,天津,重庆,河北,山西,辽宁,吉林,黑龙江,江苏,浙江,安徽,福建,江西,山东,河南,湖北,湖南,其他"; $data=explode(",",$content); for($index=0;$index<count($data);$index++){ echo $data[$index]; echo "</br>"; } ?>
相关文章推荐
- php入门到精通全系列视频(2008最新)
- 传智播客_韩顺平_php从入门到精通_视频教程_第一部分
- 韩顺平_php从入门到精通_视频教程_第14讲_盒子模型经典应用②_作业布置_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第19讲_网站推荐_定位_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第18讲_浮动_学习笔记_源代码图解_PPT文档整理
- php入门到精通全系列视频(2008最新,高清视频)
- 韩顺平_php从入门到精通_视频教程_学习笔记_源代码图解_PPT文档整理_目录
- 韩顺平_php从入门到精通_视频教程_第12讲_通配符选择器_父子选择器_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第11讲_初识css_类选择器_id选择器_html选择器_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第21讲_解答学员问题_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第0讲_开山篇_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第4讲_图像_表格_实际应用-菜谱_课堂练习-课程表_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第3讲_符号实体_url说明_超链接_发送电邮_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第13讲_选择器使用细节_块元素和行内元素_盒子模型_盒子模型经典应用①_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第8讲_多媒体页面_标签汇总①_地图映射_学习笔记_源代码图解_PPT文档整理
- php 开发入门到精通很难吗?
- 韩顺平_php从入门到精通_视频教程_第2讲_html运行原理②_html文件基本结构_html元素和属性_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第6讲_浮动窗口_表单及表单控件①_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第16讲_div-css作业评讲②_学习笔记_源代码图解_PPT文档整理
- 韩顺平_php从入门到精通_视频教程_第22讲_可爱屋首页面(浏览器兼容)评讲_学习笔记_源代码图解_PPT文档整理