|
|

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Exceed PHP - 如何使用PHP中的字符串函数</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="description" content="如何使用PHP中的字符串函数">
<meta name="keywords" content="如何使用PHP中的字符串函数">
<meta name="author" content="大A(avenger#php.net).">
<link href="/templates/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" language="javascript">
var currentpos,timer;
function initialize()
{
timer=setInterval("scrollwindow()",2);
}
function sc(){
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>
</head>
<body>
<table width="765" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#328D3A">
<tr>
<td><img src="/images/spacer.gif" width="1" height="5" alt=""></td>
<td width="5" bgcolor="#32853A"><img src="/images/spacer.gif" width="5" height="1" alt=""></td>
</tr>
</table>
<!-- NAV BAR BEGIN -->
<table width="765" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#397D3E">
<tr>
<td width="222"><a href="/"><img src="/inc/logo.php" width="222" height="57" border="0" alt="超越PHP"></a></td>
<td align="right" valign="bottom">
<a href="/?n=News" title="News"><span class="cn1">PHP动态</span></a>
<font class="en1"> | </font> <a href="/?n=Articles" title="Articles"><span class="cn1"> 经典文章</span></a>
<font class="en1"> | </font> <a href="/?n=Classes" title="Classes"><span class="cn1"> CLASS</span></a>
<font class="en1"> | </font> <a href="/?n=Download" title="Downloads"><span class="cn1"> 相关下载</span></a>
<font class="en1"> | </font> <a href="/?n=Faq" title="F & Q"><span class="cn1"> 常见问题</span></a>
<font class="en1"> | </font> <a href="/?n=Forum" title="Forum"><span class="cn1"> FORUM</span></a>
<font class="en1"> | </font> <a href="/?n=Wiki" title="Wiki"><span class="cn1"> WIKI</span></a>
<font class="en1"> | </font> <a href="/?n=Manual" title="Online Manual"><span class="cn1">在线手册</span></a>
</td>
<td width="5" bgcolor="#39753E"><img src="/images/spacer.gif" width="5" height="1" alt=""></td>
</tr>
</table>
<!-- NAV BAR END -->
<table width="765" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td><img src="/images/spacer.gif" width="1" height="1" alt=""></td>
<td width="5" bgcolor="#333333"><img src="/images/spacer.gif" width="5" height="1" alt=""></td>
</tr>
</table>
<!-- SEARCH BEGIN -->
<form name="search" method="get" action="/site_search.php">
<table width="765" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#007770">
<tr>
<td align="right" class="en1" valign="bottom">
<font color="#FFFFFF" class="small">Site <u>s</u>earch:</font>
<input name="search" type="text" class="en1" size="15" maxlength="20" value="" accesskey="s">
<input name="submit" type="image" src="/images/submit.gif" alt="Search">
</td>
<td width="10"> </td>
<td width="5" bgcolor="#006C70"><img src="/images/spacer.gif" width="5" height="1" alt=""></td>
</tr>
</table>
</form>
<!-- SEARCH END -->
<table width="765" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td><img src="/images/spacer.gif" width="1" height="1" alt=""></td>
<td width="5" bgcolor="#333333"><img src="/images/spacer.gif" width="5" height="1" alt=""></td>
</tr>
</table>
<!-- MAIN TABLE START -->
<table width="765" align="center" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;">
<tr>
<td valign="top" colspan="3" bgcolor="#FEFEFE">
<table align="CENTER" width="98%" border="0" cellspacing="8" cellpadding="4">
<tr>
<td><a href="/"><img border=0 src="/images/home_1.gif" alt="Home" align="absmiddle"></a> <a href="/">首页</a><b><span style='font-size: 7pt' lang='zh-cn'> » </span></b><a href='/?n=Articles'>经典文章</a><b><span style='font-size: 7pt' lang='zh-cn'> » </span></b> 文章查看</td>
</tr>
</table>
<table align="CENTER" width="90%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td align="CENTER" height="18"><h4>如何使用PHP中的字符串函数</h4>
<hr size=1>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr><td> </td></tr>
<tr>
<td width=580 style="word-wrap:break-word; font-size: 14px; line-height: 160%"><P><SPAN style=\"FONT-SIZE: 9pt; LINE-HEIGHT: 15pt\">PHP中的字符串操作功能是比较多的,重要的有以下这些: <BR><BR><STRONG>(1)echo,print,printf,sprintf <BR></STRONG>前两个函数是输出字符串.字符串中如果有变量名则被替换成其值. <BR>后两个函数类似于C的同名函数. <BR><BR><STRONG>(2)strchr,strlen,strtok,strrchr,strrev,strstr,strtolower, <BR></STRONG>strtoupper,substr,ucfirst <BR>这些是常用的字符串操作函数,有些和C中的同名函数意义完全一致. <BR>strrev是把一个字符串翻转. <BR>strtolower和strtoupper的意思应该不用解释了. <BR>ucfirst是把字符串的第一个字符变成大写. <BR>substr是返回字符串的一个子串,用法是:substr(字符串,头,长度).<BR>头位置是 从0算起的.如果是负数,则是从尾部向前数的意思. <BR><BR><STRONG>(3)Chr,Ord <BR></STRONG>类似于C的同名函数. <BR><BR><STRONG>(4)explode,implode,join <BR></STRONG>这些是和数组有关的函数. <BR>explode(字符串,分割符)返回一个将字符串在分割符处分开所产生的数组. <BR>implode(数组,分割符)返回一个将数组各元素之间插上分割符而成的字符串. <BR>join与implode意义相同. <BR><BR><STRONG>(5)Chop <BR></STRONG>去掉字符串尾部的空白. <BR><BR><STRONG>(6)htmlspecialchars <BR></STRONG>将字符串中的HTML特殊字符换成它们的名字,例如\"<\"变成\"<\". <BR><BR><STRONG>(7)nl2br <BR></STRONG>在字符串中的每一个回车前面加上\"<BR>\". <BR><BR><STRONG>(8)AddSlashes,StripSlashes <BR></STRONG>分别给字符串中需要加上\"\\"才能用于数据库查询的字符加上和去掉\"\\". <BR><BR><STRONG>(9)parse_str <BR></STRONG>将\"name1=value1&name2=value2&...\"类型的字符串分析成一些变量. <BR>例如: <BR> parse_str(\"a=1&b=2\"); <BR>生成$a与$b两个变量,值分别为1,2. <BR>如果有两对名字/值的名字部分相同,则后一个的值覆盖前一个的. <BR>如果这两对的名字尾部都有\"[]\",例如\"a[]=1&a[]=2\",则生成数组$a,两个元素分别为1,2</SPAN></P>
<P><SPAN style=\"FONT-SIZE: 9pt; LINE-HEIGHT: 15pt\"></SPAN> </P></td>
</tr>
<tr>
<td align="RIGHT">(责任编辑:超越PHP)</td>
</tr>
</table>
<table align="CENTER" width="85%" border="0" cellspacing="3" cellpadding="0">
<tr>
<td width="50%"><a href="/sendmail.php?aid=206" title="Send to Friend">[推荐给朋友]</a> <a href="/print.php?aid=206" title="Print" target="_blank">[显示打印版本]</a> </td>
<td align="RIGHT" width="50%">更新日期:2002-10-10 浏览次数:<script language='Javascript' src='/view.php?aid=206'></script></td>
</tr>
<tr>
<td align="center" colspan="2"><br>
<a href='http://www.phpe.net/ads/adclick.php?n=a79c4423' target='_blank'><img src='http://www.phpe.net/ads/adview.php?what=zone:4&n=a79c4423' border='0' alt=''></a>
</td>
</tr>
</table>
<script language="JavaScript" src="/note_show.php" type="text/javascript"></script>
</td>
<td valign="top" width="1" class="bg"><img src="/images/spacer.gif" alt="" width="1" height="1"></td>
<td valign="top" width="20%" bgcolor="#DDDDDD"><br>
<table align="CENTER" width="95%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td bgcolor="#666666" class="cn1"> <img src="/images/arrow.gif" alt="" border=0> 相关文章</td>
</tr>
</table>
<table align="CENTER" width="95%" border="0" cellspacing="3" cellpadding="0">
<tr>
<td> <ul><li><a href='/articles/185.shtml' title='PHP中如何使用header发送头部信息'>PHP中如何使用header发送头部信息</a></li>
</ul> </td>
</tr>
</table></td>
<td width="5" bgcolor="#BBBBBB"><img src="/images/spacer.gif" alt="" width="5" height="1"></td>
</tr>
</table>
<!-- MAIN TABLE END -->
<table width="765" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td><img src="/images/spacer.gif" width="1" height="1" alt=""></td>
<td width="5" bgcolor="#333333"><img src="/images/spacer.gif" width="5" height="1" alt=""></td>
</tr>
</table>
<table width="765" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#007770">
<tr>
<td align="right">
<a href="/?n=Source&file=article_show.php" title="查看源码"><span class="en2">view source</span></a> |
<a href="/?n=FeedBack" title="留言反馈" target="_blank"><span class="en2">feedback</span></a> |
<a href="javascript:void(0)" onclick="window.open('/site_send.php?n=www.phpe.net%2F%3Fn%3DReadArticle%26update%3D1%26a%3D206','','scrollbars=no,top=200,left=200,width=297,height=186')" title="发送链接"><span class="en2">send page</span></a> |
<a href="/?n=SiteMap" title="站点地图"><span class="en2">sitemap</span></a> |
<a href="/?n=Aboutus" title="关于我们"><span class="en2">aboutus</span></a>
</td>
<td width="5" bgcolor="#006C70"><img src="/images/spacer.gif" width="5" height="1" alt=""></td>
</tr>
</table>
<table width="765" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td><img src="/images/spacer.gif" width="1" height="1" alt=""></td>
<td width="5" bgcolor="#333333"><img src="/images/spacer.gif" width="5" height="1" alt=""></td>
</tr>
</table>
<table width="765" align="center" border="0" cellspacing="0" cellpadding="0" bgcolor="#BBBBBB">
<tr>
<td align="right" height="40">
<small>
Copyright © 2002-2004 PHPE TEAM. All rights reserved<br>
Last updated:Wed Aug 11 05:54:01 2004 CST<br>
Server sponsored by <a href="http://cncms.org"><small>cncms.org</small></a>
</small>
<br clear="all" />
<img src="http://counter.china-channel.com/counter/count.exe?df=phpe.net&reload=F&dd=e&ft=0">
</td>
<td width="10"> </td>
<td width="5" bgcolor="#AAAAAA"><img src="/images/spacer.gif" width="5" height="1" alt=""></td>
</tr>
</table>
<script language="JavaScript" type="text/javascript" src="/js/pphlogger.js"></script>
<script language="JavaScript" type="text/javascript" src="/site_online.php?hide=1&file=article_show.php"></script>
</body>
</html> |
|