php基础教程字符.docx

上传人:b****4 文档编号:24904352 上传时间:2023-06-02 格式:DOCX 页数:29 大小:17.93KB
下载 相关 举报
php基础教程字符.docx_第1页
第1页 / 共29页
php基础教程字符.docx_第2页
第2页 / 共29页
php基础教程字符.docx_第3页
第3页 / 共29页
php基础教程字符.docx_第4页
第4页 / 共29页
php基础教程字符.docx_第5页
第5页 / 共29页
点击查看更多>>
下载资源
资源描述

php基础教程字符.docx

《php基础教程字符.docx》由会员分享,可在线阅读,更多相关《php基础教程字符.docx(29页珍藏版)》请在冰豆网上搜索。

php基础教程字符.docx

php基础教程字符

php基础教程-字符

一获取字符串的长度

index.php:

phpecho$PHP_SELF;?

>">

求字符串的长度

字符串:

 



php

if($_POST[str]!

="")

{

$str=$_POST[str];

echo"字符串'".$str."'的长度是".strlen($str)."";

}

?

>

二字符串大小写转换

index.php:

php$PHP_SELF?

>">


 

php

if($_POST[submit1]!

="")

{

$str=$_POST[str];

echo$str."全部转换为大写字母为".strtoupper($_POST[str]);

}

if($_POST[submit2]!

="")

{

$str=$_POST[str];

echo$str."全部转换为写字母为".strtolower($_POST[str]);

}

?

>

三字符串首尾空格处理

index.php:

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"

"http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

php基础教程:</p><p>字符串首尾空格处理|

--

.STYLE1{

color:

#FF0000;

font-weight:

bold;

}

-->

phpecho$PHP_SELF;?

>">

字符串首尾空格处理

字符:

 



php

if($_POST[submit1]!

="")

{

$str=$_POST[str];

echo$str."去除左空格的结果为".ltrim($str);

}

if($_POST[submit2]!

="")

{

$str=$_POST[str];

echo$str."去除右空格的结果为".rtrim($str);

}

if($_POST[submit3]!

="")

{

$str=$_POST[str];

echo$str."去除左右所有空格的结果为".trim($str);

}

?

>

四字符串的逆序输出

index.php:

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"

"http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

字符串的逆序输出|

--

.STYLE1{

color:

#FFFFFF;

font-weight:

bold;

}

-->

字符串的逆序输出

字符串:

 

 

 

 

result.php:

php

$str=$_POST[str];

echo$str."逆序输出的结果是".strrev($str);

?

>

五字符串的格式化输出

index.php:

php

printf("%'@20s","mingrisoft");

echo"
";

printf("%'#10.5f",12,345);

echo"
";

printf("%b",10);

echo"
";

printf("%o",10);

echo"
";

printf("%x",10);

echo"
";

printf("%X",10);

?

>

六字符串的分割与连接

index_1.php:

--

.STYLE1{color:

#FFFFFF}

-->

字符串的分割

字符串:

 

按以下字符进行:

 

index_2.php:

--

.STYLE1{color:

#FFFFFF}

-->

字符串的连接

字符串1:

 

字符串2:

 

字符串3:

 

按以下字符连接:

 

result_1.php:

php

$str1=$_POST[str1];

$str2=$_POST[str2];

$array=explode($str2,$str1);

echo"该字符串分割结果为:

"."
";

while(list($name,$value)=each($array))

{

echo$value."
";

}

?

>

result_2.php:

php

$str1[0]=$_POST[str11];

$str1[1]=$_POST[str12];

$str1[2]=$_POST[str13];

$str2=$_POST[str2];

$str=implode($str2,$str1);

echo"该字符串合并结果为:

"."
";

echo$str;

?

>

七字符串的查找

index.php:

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"

"http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

字符串的查找|

--

.STYLE1{color:

#FFFFFF}

-->

字符串查找

原字符串:

 

要查找的字符串:

 


php

if($_POST[submit]!

="")

{

$str1=$_POST[str1];

$str2=$_POST[str2];

echo"要查找的字符串在原字符串中的位置是:

".(strpos($str1,$str2)+1)."";

}

?

>

八字符串的大小比较

index.php:

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"

"http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

php基础教程:</p><p>字符串的大小比较|<title></p><p><linkrel="stylesheet"type="text/css"href="style.css"></p><p><styletype="text/css"></p><p><!</p><p>--</p><p>.STYLE1{color:</p><p>#FFFFFF}</p><p>--></p><p></style></p><p></head></p><p><body></p><p><tablewidth="250"height="100"border="0"align="center"cellpadding="0"cellspacing="0"></p><p><tr></p><p><tdbgcolor="#666666"><tablewidth="250"height="100"border="0"cellpadding="0"cellspacing="1"></p><p><formname="form1"method="post"action="index.php"></p><p><tr></p><p><tdheight="25"colspan="2"bgcolor="#666666"></p><p><divalign</p> </div> <div class="readmore" onclick="showmore()" style="background-color:transparent; height:auto; margin:0px 0px; padding:20px 0px 0px 0px;"><span class="btn-readmore" style="background-color:transparent;"><em style=" font-style:normal">展开</em>阅读全文<i></i></span></div> <script> function showmore() { $(".readmore").hide(); $(".detail-article").css({ "height":"auto", "overflow": "hidden" }); } $(document).ready(function() { var dh = $(".detail-article").height(); if(dh >100) { $(".detail-article").css({ "height":"100px", "overflow": "hidden" }); } else { $(".readmore").hide(); } }); </script> </div> <script> var defaultShowPage = parseInt("5"); var id = "24904352"; var total_page = "29"; var mfull = false; var mshow = false; function DownLoad() { window.location.href='https://m.bdocx.com/down/24904352.html'; } function relate() { var reltop = $('#relate').offset().top-50; $("html,body").animate({ scrollTop: reltop }, 500); } </script> <script> var pre = "https://file1.bdocx.com/fileroot1/2023-6/2/08455cf1-7e10-4369-b45f-fd50aa508051/08455cf1-7e10-4369-b45f-fd50aa508051"; var freepage = parseInt('20'); var total_c = parseInt('29'); var start = defaultShowPage; var adcount = 0; var adindex = 0; var adType_list = ";0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;"; var end = start; function ShowSvg() { end = start + defaultShowPage; if (end > freepage) end = freepage; for (var i = start; i < end; i++) { var imgurl = pre + (i + 1) + '.gif'; var html = "<img src='" + imgurl + "' onerror=\"this.src='/images/s.gif'\" alt=\"php基础教程字符.docx_第" + (i + 1) + "页\" width='100%'/>"; $("#page").append("<div class='page'>" + html + "</div>"); $("#page").append("<div class='pageSize'>第" + (i + 1) + "页 / 共" + total_c + "页</div>"); if(adcount > 0 && adType_list.indexOf(";"+(i+1)+";")>-1) { if(adindex > (adcount-1)) adindex = 0; $("#page").append("<div class='pagead' id='addiv"+(i + 1)+"'></div>"); document.getElementById("addiv"+(i + 1)+"").innerHTML =document.getElementById("adpre" + adindex).outerHTML; adindex += 1; } } start = end; if (start > (freepage - 1)) { if (start < total_c) { $("#pageMore").removeClass("btnmore"); $("#pageMore").html("亲,该文档总共" + total_c + "页,到这儿已超出免费预览范围,如果喜欢就下载吧!"); } else { $("#pageMore").removeClass("btnmore"); $("#pageMore").html("亲,该文档总共" + total_c + "页全部预览完了,如果喜欢就下载吧!"); } } } //$(document).ready(function () { // ShowSvg(); //}); </script> <div id="relate" class="container" style="padding:0px 0px 15px 0px; margin-top:20px; border:solid 1px #dceef8"> <div style=" font-size: 16px; background-color:#e5f0f7; margin-bottom:5px; font-weight: bold; text-indent:10px; line-height: 40px; height:40px; padding-bottom: 0px;">相关资源</div> <div id="relatelist" style="padding-left:5px;"> <ul> <li><em class="docx"/></em><a target="_parent" href="https://m.bdocx.com/doc/30868134.html" title="初中语文必考古诗词文学常识.docx">初中语文必考古诗词文学常识.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bdocx.com/doc/30868133.html" title="初中复习资料:语文语法知识.docx">初中复习资料:语文语法知识.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bdocx.com/doc/30868132.html" title="初中语文文言文常见的25个虚词用法汇总.docx">初中语文文言文常见的25个虚词用法汇总.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bdocx.com/doc/30868131.html" title="七下语文期中古诗文理解性默写专练.docx">七下语文期中古诗文理解性默写专练.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bdocx.com/doc/30868130.html" title="初中语文易错字总结.docx">初中语文易错字总结.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bdocx.com/doc/30868129.html" title="初中语文1-6册文言文重要语句翻译.docx">初中语文1-6册文言文重要语句翻译.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bdocx.com/doc/30868128.html" title="初中语文万能作文结尾25段.docx">初中语文万能作文结尾25段.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bdocx.com/doc/30868127.html" title="初中语文8大类基础知识的归纳总结.docx">初中语文8大类基础知识的归纳总结.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bdocx.com/doc/30868126.html" title="初中语文名著复习:《昆虫记》及考点练习.docx">初中语文名著复习:《昆虫记》及考点练习.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bdocx.com/doc/30868125.html" title="初中七年级上册语文课内文言文知识点汇总.docx">初中七年级上册语文课内文言文知识点汇总.docx</a> </li> </ul> </div> </div> <div class="container" style="padding:0px 0px 15px 0px; margin-top:20px; border:solid 1px #dceef8"> <div style=" font-size: 16px; background-color:#e5f0f7; margin-bottom:5px; font-weight: bold; text-indent:10px; line-height: 40px; height:40px; padding-bottom: 0px;">猜你喜欢</div> <div id="relatelist" style="padding-left:5px;"> <ul> <li><em class="docx"></em> <a href="https://m.bdocx.com/doc/24704654.html" target="_parent" title="湖北省鄂东南省级示范高中届高三上学期期中联考物理试题 含答案.docx">湖北省鄂东南省级示范高中届高三上学期期中联考物理试题 含答案.docx</a></li> <li><em class="docx"></em> <a href="https://m.bdocx.com/doc/24704655.html" target="_parent" title="建筑工地管理制度汇总.docx">建筑工地管理制度汇总.docx</a></li> <li><em class="docx"></em> <a href="https://m.bdocx.com/doc/24704656.html" target="_parent" title="江苏大学发展党员工作规定.docx">江苏大学发展党员工作规定.docx</a></li> <li><em class="docx"></em> <a href="https://m.bdocx.com/doc/24704657.html" target="_parent" title="江苏省苏州市届高三第一次质量检测英语试题含答案.docx">江苏省苏州市届高三第一次质量检测英语试题含答案.docx</a></li> <li><em class="docx"></em> <a href="https://m.bdocx.com/doc/24704658.html" target="_parent" title="华而不实打一植物名.docx">华而不实打一植物名.docx</a></li> <li><em class="docx"></em> <a href="https://m.bdocx.com/doc/24704659.html" target="_parent" title="建设工程施工合同通用合同条款.docx">建设工程施工合同通用合同条款.docx</a></li> <li><em class="docx"></em> <a href="https://m.bdocx.com/doc/24704660.html" target="_parent" title="化工人必知的化工装置常见安全隐患300项 1概要.docx">化工人必知的化工装置常见安全隐患300项 1概要.docx</a></li> <li><em class="docx"></em> <a href="https://m.bdocx.com/doc/24704661.html" target="_parent" title="湖南汨罗屈子祠保护规划说明.docx">湖南汨罗屈子祠保护规划说明.docx</a></li> <li><em class="docx"></em> <a href="https://m.bdocx.com/doc/24704662.html" target="_parent" title="教科版小学三年级下册品德与社会教学计划教案.docx">教科版小学三年级下册品德与社会教学计划教案.docx</a></li> </ul> </div> </div> <div style=" font-size: 16px; background-color:#e5f0f7; margin-top:20px; font-weight: bold; text-indent:10px; line-height: 40px; height:40px; padding-bottom: 0px; margin-bottom:10px;"> 相关搜索</div> <div class="widget-box pt0" style="border: none; padding:0px 5px;"> <ul class="taglist--inline multi"> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bdocx.com/search.html?q=php">php</a></li> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bdocx.com/search.html?q=%e5%9f%ba%e7%a1%80%e6%95%99%e7%a8%8b">基础教程</a></li> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bdocx.com/search.html?q=%e5%ad%97%e7%ac%a6">字符</a></li> </ul> </div> <br /> <div > 当前位置:<a target="_parent" href="https://m.bdocx.com/">首页</a> > <a href="https://m.bdocx.com/booklist-00018.html">初中教育</a><span> > </span><a href="https://m.bdocx.com/booklist-0001800001.html">语文</a> </div> <br /> <div class="cssnone"> <iframe title="来源" src="https://m.bdocx.com/BookRead.aspx?id=80qc8HWXWpfC%2fyc3X17kyA%3d%3d&parto=sFMznlm8lMqPirE36gCXb5qHQkNt68qEgG0inbwPvPzmNk8bGqpbg9KXwNT9jTAd366f82qtqf3qDH81ZEno%2bWcE77AiUYaR1TqOllGWd%2bpJETBebF1xp6lAYf7lHWroex2GxnqBOTsulaN1apzTMNIQNeI8649%2btRrl2ET%2b1USGNfvFTXfQsfd8qd39K1fNG18u1hS0Lzk7Ud24iQY2Mbe4s5ZmlfT5" frameborder="0" style="width: 0px; height: 0px"> </iframe> </div> <span id="LabelScript"></span> <script src="https://mstatic.bdocx.com/JS/bootstrap-collapse.js"></script> </form> <div class="siteInner_bg" style="margin-top: 40px; border: solid 0px red; margin-left: 0px; margin-right: 0px;"> <div class="siteInner"> <p style="text-align: center;">copyright@ 2008-2022 冰豆网网站版权所有</p><p style="text-align: center;">经营许可证编号:<a href="http://beian.miit.gov.cn/" target="_blank">鄂ICP备2022015515号-1</a></p><script>var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?2e77bd3f6fe91b0e21d3f22267249ee3"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script><script>(function(){ var el = document.createElement("script"); el.src = "https://lf1-cdn-tos.bytegoofy.com/goofy/ttzz/push.js?81476e42bf626128cf29544ee216a8ed7deb9487dce7ed62313212129c4244a219d1c501ebd3301f5e2290626f5b53d078c8250527fa0dfd9783a026ff3cf719"; el.id = "ttzz"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(el, s); })(window)</script> </div> </div> <div class="trnav clearfix" id="navcontent" style="display: none; background-color:#3a71b1; "> <div class="trlogoside" id="navlogo" style="display: none;"> <a href="https://m.bdocx.com/" title="冰豆网"><img src="https://www.bdocx.com/images/logo_bd.png" alt="冰豆网"></a> <div class="trnavclose" id="navclose"> <span></span> </div> </div> <div class="navcontainer"> <div class="row"> <ul class="nav navbar-nav trnavul headercontent" id="navigation" style="margin:20px 0 0px;"> <li><a target="_parent"href="https://m.bdocx.com/login.aspx">登录</a></li> <li><a target="_parent"href="https://m.bdocx.com/">首页 </a></li> <li><a target="_parent"href="https://m.bdocx.com/booklist-0.html">资源分类 </a></li> <li><a target="_parent"href="https://m.bdocx.com/UserManage/Recharge.aspx?f=0"><img src="https://m.bdocx.com/images/s.gif" alt="new" class="hottip1">升级会员 <img src="https://www.bdocx.com/FileUpload/Images/48520fea-bc98-41ae-b183-84689c7075c9.gif" alt="new" class="hottip"></a></li> <li><a target="_parent"href="https://m.bdocx.com/newslist.html">通知公告 </a></li> <li><a target="_parent"href="https://m.bdocx.com/h-0.html">帮助中心 </a></li> </ul> </div> </div> </div> <script type="text/javascript"> function stopPropagation(e) { var ev = e || window.event; if (ev.stopPropagation) { ev.stopPropagation(); } else if (window.event) { window.event.cancelBubble = true;//兼容IE } } $("#navmore").click(function (e) { $("#navcontent").show(); $("#navlogo").show(); stopPropagation(e); var navcontentwidth = $("#navcontent").width(); $('#navcontent').css({ 'right': '-' + navcontentwidth + 'px' }); $("#navcontent").show().animate({ "right": 0 }, 300); }); $(document).bind('click', function () { var navcontentwidth = $("#navcontent").width(); $("#navcontent").animate({ 'right': '-' + navcontentwidth + 'px' }, 300, function () { $("#navcontent").hide(); }); $("#navlogo").fadeOut(300); }); $("#navcontent").click(function (e) { stopPropagation(e); }); $("#navclose").click(function (e) { var navcontentwidth = $("#navcontent").width(); $("#navcontent").animate({ 'right': '-' + navcontentwidth + 'px' }, 300, function () { $("#navcontent").hide(); }); $("#navlogo").fadeOut(300); }); </script> <script> function BaseShare(title, desc, imgUrl) { var link = "https://m.bdocx.com/doc/24904352.html"; if (wx) { wx.config({ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: 'wx4f717640abfd1120', // 必填,公众号的唯一标识 timestamp: '1725589206', // 必填,生成签名的时间戳 nonceStr: '4F6FFE13A5D75B2D6A3923922B3922E5', // 必填,生成签名的随机串 signature: '3c28e3e67d72e3221ace867a012ae70321ab90d2',// 必填,签名,见附录1 jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline', 'updateAppMessageShareData', 'updateTimelineShareData', 'hideMenuItems'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 //openTagList: ["wx-open-launch-weapp"]//H5打开小程序 }); wx.ready(function () { //需在用户可能点击分享按钮前就先调用 wx.hideMenuItems({// 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3 menuList: ['menuItem:share:qq', 'menuItem:favorite', 'menuItem:share:QZone', 'menuItem:share:email', 'menuItem:originPage', 'menuItem:readMode', 'menuItem:delete', 'menuItem:editTag', 'menuItem:share:facebook', 'menuItem:share:weiboApp', 'menuItem:share:brand'] }); var shareData = { title: title, // 分享标题 desc: desc,//这里请特别注意是要去除html link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: imgUrl, // 分享图标 }; wx.updateAppMessageShareData(shareData);//1.4 分享到朋友 wx.updateTimelineShareData(shareData);//1.4分享到朋友圈 }); } } function BaseShare(title, desc, imgUrl, link) { if (link=="") link = "https://m.bdocx.com/doc/24904352.html"; if (wx) { wx.config({ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: 'wx4f717640abfd1120', // 必填,公众号的唯一标识 timestamp: '1725589206', // 必填,生成签名的时间戳 nonceStr: '4F6FFE13A5D75B2D6A3923922B3922E5', // 必填,生成签名的随机串 signature: '3c28e3e67d72e3221ace867a012ae70321ab90d2',// 必填,签名,见附录1 jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline', 'updateAppMessageShareData', 'updateTimelineShareData', 'hideMenuItems'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 //openTagList: ["wx-open-launch-weapp"]//H5打开小程序 }); wx.ready(function () { //需在用户可能点击分享按钮前就先调用 wx.hideMenuItems({// 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3 menuList: ['menuItem:share:qq', 'menuItem:favorite', 'menuItem:share:QZone', 'menuItem:share:email', 'menuItem:originPage', 'menuItem:readMode', 'menuItem:delete', 'menuItem:editTag', 'menuItem:share:facebook', 'menuItem:share:weiboApp', 'menuItem:share:brand'] }); var shareData = { title: title, // 分享标题 desc: desc,//这里请特别注意是要去除html link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: imgUrl, // 分享图标 }; wx.updateAppMessageShareData(shareData);//1.4 分享到朋友 wx.updateTimelineShareData(shareData);//1.4分享到朋友圈 }); } } </script> <script> $(document).ready(function () { var arr = $(".headercontent"); for (var i = 0; i < arr.length; i++) { (function (index) { var url = "https://m.bdocx.com/header.aspx"; $.get(url + "?t=" + (new Date()).valueOf(), function (d) { try { arr.eq(index).empty().html(d); } catch (e) { } try { arr.html(d); } catch (e) { } }); })(i); } }); </script> <script src="https://mstatic.bdocx.com/js/jquery.lazyload.js"></script> <script charset="utf-8"> $("img.lazys").lazyload({ threshold: 200, effect: "fadeIn" }); </script> </body> </html>