<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>wewe&#039;s blog &#187; php</title>
	<atom:link href="http://imwewe.com/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://imwewe.com</link>
	<description>&#124;From here to somewhere</description>
	<lastBuildDate>Fri, 25 Nov 2011 23:36:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<atom:link rel='hub' href='http://imwewe.com/?pushpress=hub'/>
		<item>
		<title>PHP常用函数库</title>
		<link>http://imwewe.com/2009/04/php.html</link>
		<comments>http://imwewe.com/2009/04/php.html#comments</comments>
		<pubDate>Thu, 23 Apr 2009 11:18:10 +0000</pubDate>
		<dc:creator>wewe</dc:creator>
				<category><![CDATA[分享]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://imwewe.com/?p=590</guid>
		<description><![CDATA[PHP常用库函数

I/O函数

Flush

<span class="readmore"><a href="http://imwewe.com/2009/04/php.html" title="PHP常用函数库">阅读全文——共18977字</a></span>]]></description>
			<content:encoded><![CDATA[<p align="center"><strong>PHP</strong><strong>常用库函数</strong></p>
<p><strong>I/O</strong><strong>函数</strong></p>
<p><strong>Flush</strong></p>
<p>函数描述：flush();</p>
<p>说明：函数Flush刷新PHP的输出缓存，它尽量将缓和存中的内容输出到用户的浏览器。</p>
<p>返回值：无</p>
<p><strong>Print</strong></p>
<p>函数描述：print(string arg,string[arg],...);</p>
<p>说明：函数print输入所有的参数。</p>
<p>返回值：若输出成功，返回true(1);否则返回false(0)。</p>
<p><strong>Printf</strong></p>
<p>函数描述：printf(string format,mixed[string]);</p>
<p>说明：函数printf根据所给格式format，输出string。格式以一个%开头，以一个字母结尾，该字母决定输出的数据类型。PHP的类型说明符如表所示。</p>
<p>PHP的类型说明符</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="151" valign="top">
<p align="center"><strong>类型说明符</strong></p>
</td>
<td width="417" valign="top">
<p align="center"><strong>说 </strong><strong>明</strong></p>
</td>
</tr>
<tr>
<td width="151" valign="top">
<p align="center">b</p>
</td>
<td width="417" valign="top">输出二进制整数</td>
</tr>
<tr>
<td width="151" valign="top">
<p align="center">o</p>
</td>
<td width="417" valign="top">输出八进制整数</td>
</tr>
<tr>
<td width="151" valign="top">
<p align="center">x,X</p>
</td>
<td width="417" valign="top">输出十六进制整数，"x"使用小写字母，"X"使用大写字母</td>
</tr>
<tr>
<td width="151" valign="top">
<p align="center">d</p>
</td>
<td width="417" valign="top">输出十进制整数</td>
</tr>
<tr>
<td width="151" valign="top">
<p align="center">c</p>
</td>
<td width="417" valign="top">输出由整数ASCII代码说明的字符</td>
</tr>
<tr>
<td width="151" valign="top">
<p align="center">s</p>
</td>
<td width="417" valign="top">输出字符串</td>
</tr>
<tr>
<td width="151" valign="top">
<p align="center">f</p>
</td>
<td width="417" valign="top">输出浮点数</td>
</tr>
<tr>
<td width="151" valign="top">
<p align="center">e</p>
</td>
<td width="417" valign="top">输出用科学计数法表示的浮点数</td>
</tr>
<tr>
<td width="151" valign="top">
<p align="center">%</p>
</td>
<td width="417" valign="top">输出一个百分号</td>
</tr>
</tbody>
</table>
<p>返回值：无</p>
<p align="left"><strong>正规表达式函数</strong></p>
<p><strong>Ereg</strong></p>
<p>函数描述：int ereg （string pattern ，string string ，array[regs]）；</p>
<p>说明：函数ereg在参数string中寻找pattern中给出的正规表达式相匹配的项。如果提供了可选reg数组，则每一项匹配将顺序存储在数组regs[1]开始的各项中。在regs[0]中存储整个正规表达式的匹配项。在函数ereg中，匹配的辨别是区分大小写的。请参看以下程序</p>
<p>返回值：若至少有一处匹配则函数ereg返回true（1）；否则返回false（0）。</p>
<p>例子：</p>
<p>&lt;？</p>
<p>$date="2000-5-4";</p>
<p>if (ereg("([0-9]){4})-([0-9]{1,2}-([0-9]){1,2})",$date,$regs))</p>
<p>{</p>
<p>print("$regs[3].$regs[2].$regs[1]");</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>print("输出时间格式有误：$date");</p>
<p>}</p>
<p>?&gt;</p>
<p>该程序输出结果：14.5.2000</p>
<p><strong>Ereg_replace</strong></p>
<p>函数描述：string Ereg_replace(string pattern,string replacement,string string);</p>
<p>说明：函数Ereg_replace可用于替换文本，当参数pattern与参数string中的字串匹配时，他就被参数replacement的内容所替换。若参数pattern中包含有圆括号的子表达式，则在参数replacement中可以用包含特定的代码来说明哪个子表达式被替换，最多可以有九个子表达式。其具体形式是用两个反斜杠后跟一个从0~9的单数字，0表示与整个表达式相匹配，1~9表示相应的与前1~9个子表达式相匹配。注意，参数pattern中的圆括号是可以嵌套的，其表达式序号等于该表达式前的圆括号的数目。</p>
<p>返回值：函数ereg_eplace返回替换后的字符串pattern。</p>
<p><strong>Eregi</strong></p>
<p>函数描述：int eregi(string pattern , string string , array[regs]);</p>
<p>说明：函数eregi与ereg相类似，不同之处是函数eregi进行匹配时不区分大小写。</p>
<p>返回值：若至少有一处相匹配，函数eregi返回true(1),否则返回false(0)。</p>
<p><strong>Eregi_replace</strong></p>
<p>函数描述：string Eregi_replace(string pattern,string replacement,string string);</p>
<p>说明：函数eregi_replace与ereg_replace相类似，不同之处就是函数eregi_replace进行匹配时不区分大小写。</p>
<p>返回值：函数eregi_eplace返回替换后的字符串pattern。</p>
<p><strong>Split</strong><strong></strong></p>
<p>函数描述：array split(string pattern,string string , int[limit]);</p>
<p>说明：函数split以参数pattern作为分界符从参数string 中取行一系列子串，并将它们存入一字符串数组。参数limit限定生成数组的大小，数组中的最后一个元素为参数string中还未分组的所有内容。</p>
<p>返回值：函数split返回生成的字符串数组，如果有一个错误，返回false(0)。</p>
<p><strong>Sql_regcase</strong></p>
<p>函数描述：string sql_regcase(string string);</p>
<p>说明：函数sql_regcase生成一个字符串数组，数组中的各个元素依次为参数string中各个字符的大小写；若在参数string中有一个空格，其对应数组元素的内容为一个空格。</p>
<p>返回值：函数sql_regcase返回所生成字符串数组。</p>
<p>例：</p>
<p>&lt;?</p>
<p>print(sql_regcase("Hello PHP"));</p>
<p>?&gt;</p>
<p>此程序结果为：[Hh][Ee][Ll][Ll][Oo][ ][Pp][Hh][Pp]</p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong>数学函数</strong></p>
<p><strong>Abs</strong></p>
<p>函数描述：mixed abs(mixed number);</p>
<p>返回值：函数abs返回参数number的绝对值。</p>
<p><strong>Acos</strong></p>
<p>函数描述：double acos(double number);</p>
<p>返回值：函数acos返回参数number的反余弦值。如果参数number大于1或小于1，则其反余弦值无意义 。</p>
<p><strong>Asin</strong></p>
<p>函数描述；double asin(double number);</p>
<p>返回值：函数asin返回参数number的反正弦值。如果参数number大于1或小于1，则其反正弦值无意义 。</p>
<p><strong>Atan</strong></p>
<p>函数描述：double atan(double number);</p>
<p>函数atan返回参数number的反正切值。</p>
<p><strong>Atan2</strong></p>
<p>函数描述：Double atan2(double x , double y);</p>
<p>返回值：函数atan2返回由直角坐标系指定的座标点在极座标系中的角度的弧度值。</p>
<p><strong>BinDec</strong></p>
<p>函数描述：int bindec(string binary_number);</p>
<p>返回值：函数bindec返回一个用二进制数写成的字符串binary_number的整数值。PHP使用32位带符号的整数，其二进制数的第一位是符号位。</p>
<p><strong>Ceil</strong></p>
<p>函数描述：int ceil(double number);</p>
<p>返回值：函数ceil返回大于参数number 的最小整数；若number为整数。，则返回其本身。</p>
<p><strong>Cos</strong><strong></strong></p>
<p>函数描述：double cos(double angle);</p>
<p>返回值：函数cos返回以弧度的大小为参数angle的角的余弦值。</p>
<p><strong>DecBin</strong></p>
<p>与bindec相反，将十进制转为二进制。</p>
<p><strong>DecHex</strong><strong>（&lt;-&gt;HexDec</strong><strong>）</strong></p>
<p>返回十六进制值</p>
<p><strong>DecOct</strong><strong>（&lt;-&gt;OctDec</strong><strong>）</strong></p>
<p>返回八进制值</p>
<p><strong>Deg2rad</strong><strong>（&lt;-&gt;Rad2reg</strong><strong>）</strong></p>
<p>函数描述：double deg2red(double angle);</p>
<p>返回值：函数deg2red返回角度数angle相对应的弧度值。</p>
<p><strong>Exp</strong></p>
<p>函数描述：double exp(double power);</p>
<p>返回值：函数exp返回自然对数的power次幂。</p>
<p><strong>Floor</strong></p>
<p>函数描述：int floor(double number);</p>
<p>返回值：返回参数number的整数部分。</p>
<p><strong>Getrandmax</strong></p>
<p>函数描述：int getrandmax();</p>
<p>返回值；返回由函数rand所能返回的最大值</p>
<p><strong>Log</strong><strong>（Log10</strong><strong>）</strong></p>
<p>函数描述：Double log(double number);</p>
<p>返回值：返回参数number的自然对数(返回以10为底的对数)</p>
<p><strong>Max (&lt;-&gt;Min)</strong></p>
<p>函数描述：mixed max(mixed arg1, mixed arg2, ...,mixed argn);</p>
<p>返回值：返回此数组中的最大值（最小值），若参数中有浮点数，则所有参数转化成浮点数，返回值也为浮点数；否则所有参数转化成整数，返回值为整数。</p>
<p><strong>pi</strong></p>
<p>函数描述：double pi（）；</p>
<p>返回值：函数pi返回圆周率的近似值。</p>
<p><strong>Pow</strong></p>
<p>函数描述：double pow（double base，double power）；</p>
<p>返回值：函数pow返回参数base的power次幂。</p>
<p><strong>Rand</strong><strong></strong></p>
<p>函数描述：int rand（int lowest，int longest）；</p>
<p>说明：函数rand使用前要用srand激活。</p>
<p>返回值：函数rand返回可选参数lowest和longest之间的一个数（包含两个参数）；若无参数，则返回值的范围从零到getrandmax返回的整数。</p>
<p><strong>Round</strong></p>
<p>函数描述：double round（double number）；</p>
<p>返回值：函数round返回最接近参数number的整数。</p>
<p><strong>Sin</strong></p>
<p>函数描述：double sin（double angle）；</p>
<p>返回值：函数sin返回一个用弧度表示的角的正弦值。</p>
<p><strong>Sqrt</strong></p>
<p>函数描述：double sqrt（double number）；</p>
<p>说明：在函数sqrt中，参数number不能小于0。</p>
<p>返回值：函数sqrt返回参数number的平方根。</p>
<p><strong>Srand</strong></p>
<p>函数描述：srand（int seed）；</p>
<p>说明：函数srand激活随机数发生器。参数seed是随机产生的种子，即所得的随机数是由参数经过一系列计算所的。</p>
<p>返回值：无。</p>
<p><strong>Tan</strong></p>
<p>函数描述：double tan（duoble angle）；</p>
<p>返回值：函数tan返回以弧度表示的角的正切值。</p>
<p><strong> </strong></p>
<p><strong>时间函数</strong></p>
<p><strong>CheckDate</strong></p>
<p>函数描述：int checkdate（int month，int date，int year）；</p>
<p>说明：在PHP中谔谔所谓合法日期，指的是参数year介于1900~32767之间，month介于1~12之间，day处于当前月的有效日期之间的日期。</p>
<p>返回值：若输入的日期合法，返回true（1）；否则返回false（0）。</p>
<p><strong>Date</strong></p>
<p>函数描述：string date(string format, int [timestamp]);</p>
<p>说明：函数date根据参数format生成一个描述日期timestamp的字符串。参数timestamp可选，若给定，则为所需的时间戳，即从1970年1月1日开始的秒数；若为空白，则使用当前日期。Format代码如下表：</p>
<p>返回值：函数date返回生成的日期描述字符串。</p>
<p align="center"><strong> </strong></p>
<p align="center"><strong>函数date</strong><strong>的format</strong><strong>代码表</strong></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="284" valign="top">
<p align="center"><strong>代 </strong><strong>码</strong></p>
</td>
<td width="284" valign="top">
<p align="center"><strong>描 </strong><strong>述</strong></p>
</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>a</strong></p>
</td>
<td width="284" valign="top">am/pm</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>A</strong></p>
</td>
<td width="284" valign="top">AM/PM</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>d</strong></p>
</td>
<td width="284" valign="top">有前导零的月份中的日期</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>D</strong></p>
</td>
<td width="284" valign="top">三字母简写形式的星期几</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>F</strong></p>
</td>
<td width="284" valign="top">月份名</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>h</strong></p>
</td>
<td width="284" valign="top">用1~12表示的小时</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>H</strong></p>
</td>
<td width="284" valign="top">用0~23表示的小时</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>I</strong></p>
</td>
<td width="284" valign="top">分钟</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>j</strong></p>
</td>
<td width="284" valign="top">没有前导零的月份中的日期</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>l</strong></p>
</td>
<td width="284" valign="top">星期几</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>m</strong></p>
</td>
<td width="284" valign="top">用1~12表示的月份</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>M</strong></p>
</td>
<td width="284" valign="top">简写月份名</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>S</strong></p>
</td>
<td width="284" valign="top">月份中日期的正序后缀</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>U</strong></p>
</td>
<td width="284" valign="top">从纪元开始的秒数</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>y</strong></p>
</td>
<td width="284" valign="top">两位的年份</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>Y</strong></p>
</td>
<td width="284" valign="top">四位的年份</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center"><strong>Z</strong></p>
</td>
<td width="284" valign="top">一年之中的日期</td>
</tr>
</tbody>
</table>
<p><strong> </strong></p>
<p><strong>Getdate</strong></p>
<p>函数描述：array getdate（int[timnestamp]）；</p>
<p>说明：函数生成一个带有所给日期信息的关联数组。参数timestamp为所需的时间戳，若为空，则使用当前日期。关联数组元素如下表所示：</p>
<p>返回值：函数getdate返回生成的关联数组。</p>
<p>函数getdate生成的关联数组元素表</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="259" valign="top">
<p align="center"><strong>元 </strong><strong>素</strong></p>
</td>
<td width="309" valign="top">
<p align="center"><strong>描 </strong><strong>述</strong></p>
</td>
</tr>
<tr>
<td width="259" valign="top">
<p align="center"><strong>hours</strong></p>
</td>
<td width="309" valign="top">24小时格式的小时</td>
</tr>
<tr>
<td width="259" valign="top">
<p align="center"><strong>mday</strong></p>
</td>
<td width="309" valign="top">月份中的日期</td>
</tr>
<tr>
<td width="259" valign="top">
<p align="center"><strong>minutes</strong></p>
</td>
<td width="309" valign="top">分钟</td>
</tr>
<tr>
<td width="259" valign="top">
<p align="center"><strong>mon</strong></p>
</td>
<td width="309" valign="top">数字形式的月份</td>
</tr>
<tr>
<td width="259" valign="top">
<p align="center"><strong>month</strong></p>
</td>
<td width="309" valign="top">月份的全称</td>
</tr>
<tr>
<td width="259" valign="top">
<p align="center"><strong>seconds</strong></p>
</td>
<td width="309" valign="top">秒数</td>
</tr>
<tr>
<td width="259" valign="top">
<p align="center"><strong>wday</strong></p>
</td>
<td width="309" valign="top">从0~6数字形式的星期几</td>
</tr>
<tr>
<td width="259" valign="top">
<p align="center"><strong>weekday</strong></p>
</td>
<td width="309" valign="top">星期几的名称</td>
</tr>
<tr>
<td width="259" valign="top">
<p align="center"><strong>yday</strong></p>
</td>
<td width="309" valign="top">一年中数字形式的日期</td>
</tr>
<tr>
<td width="259" valign="top">
<p align="center"><strong>year</strong></p>
</td>
<td width="309" valign="top">年份</td>
</tr>
<tr>
<td width="259" valign="top">
<p align="center"><strong>0</strong></p>
</td>
<td width="309" valign="top">日期戳</td>
</tr>
</tbody>
</table>
<p><strong> </strong></p>
<p><strong>MkTime</strong></p>
<p>函数描述：int mktime(int hour, int minute, int second, int month, int day, int year);</p>
<p>返回值：函数mktime返回给出日期的时间戳，即从1970年1月1日开始的秒数。所有参数都可选，若为空，则使用当前值。若某参数超过范围，函数mktime也可以正确解释。例如，用13作为月份就等于第二年的一月份。</p>
<p><strong>GmmkTime</strong></p>
<p>函数描述：int gmmktime(int hour, int minute, int second, int month, int day, int year);</p>
<p>返回值：函数gmmktime与函数mktime相类似，但不同的是他的各参数均被认为是格林威治时间。</p>
<p><strong>Time</strong></p>
<p>函数描述：int time();</p>
<p>返回值：函数time返回当前的时间戳。</p>
<p><strong>MicroTime</strong></p>
<p>函数描述：string microtime();</p>
<p>返回值：函数microtime返回一个字符串，其组成为两个由空格隔开的成员，第一个成员是系统时间的毫秒数，第二个成员是从1970年1月1日开始计的秒数，即系统时间的时间戳。</p>
<p><strong>6.2.5</strong><strong>字符串操作函数</strong></p>
<p><strong>AddSlashes</strong></p>
<p>函数描述：string addslashes（string string）；</p>
<p>说明：函数addslashes在参数string中的单引号(')、双引号（"）、反斜杠（\）和空格前添加反斜杠（\）。</p>
<p>返回值：函数addslashes返回添加后的字符串参数string。</p>
<p><strong>Chop</strong></p>
<p>函数描述：string chop（string string）；</p>
<p>返回值：函数chop去除参数string中最后一个非空字符后的所有空格，并返回生成的新字符串。</p>
<p><strong>Chr</strong></p>
<p>函数描述：string chr（int ascii）；</p>
<p>返回值：函数chr根据所给的ASCII码返回相对应的字符。</p>
<p><strong>Eval</strong></p>
<p>函数描述：eval（string phpcode）；</p>
<p>说明：函数eval将参数phpcode作为PHP脚本中的一行代码执行，括号内应用单引号或退格美元符。</p>
<p>返回值：无。</p>
<p><strong>Explode</strong></p>
<p>函数描述：array explode（string separator，string string）；</p>
<p>返回值：函数explode返回一个字符串数组，数组元素是由参数separator分隔的参数string的各段内容。</p>
<p><strong>Htmlspecialchars</strong></p>
<p>函数描述：string htmlspecialchars（string string）；</p>
<p>说明：在HTML中，某些字符与特殊意义，为保留其原意，则将他们用HTLM语言描述。</p>
<p>'&amp;'转换为"&amp;amp"</p>
<p>' " '转换为'&amp;qout'</p>
<p>'&lt;'转换为' &amp;lt '</p>
<p>'&gt;'转换为'&amp;gt'</p>
<p>返回值：函数htmlspecialchars返回转变后的字符串。</p>
<p><strong>Implode</strong></p>
<p>函数描述：string implode（array pieces ，string glue）；</p>
<p>返回值：将数组pieces依次用参数glue联结并返回生成的字符串</p>
<p><strong>Jion</strong></p>
<p>函数描述：string join（array pieces ，string glue）；</p>
<p>说明：函数jion与函数implode作用完全相同。</p>
<p><strong>Ltrim</strong></p>
<p>函数描述：string ltrim（string string）；</p>
<p>返回值：去除参数string中第一个非空字符前的所有空格，并返回生成的新字符串。</p>
<p><strong>Nl2br</strong></p>
<p>函数描述：string nl2br(string string);</p>
<p>返回值：在所有的新行前插入"&lt;br&gt;"，并生成新的字符串。</p>
<p><strong>Ord</strong></p>
<p>函数描述：int ord（string string）；</p>
<p>返回值：返回所有字符的ASCII码。</p>
<p><strong>QuoteMeta</strong></p>
<p>函数描述：string quotemeta（string string）；</p>
<p>返回值：此函数返回一个字符串，该字符串在参数string中的下列元素前加反斜杠：".""+""\\""*""?""[""]""^""("")""$"</p>
<p><strong>RawurldeCode</strong></p>
<p>函数描述：string rawurldecode（string string）；</p>
<p>返回值：将原参数字符串string中的百分号（%）及其后的两位十六进制数替换成对应的文本字符，并返回替换后的字符串。</p>
<p><strong>Sprintf</strong></p>
<p>函数描述：string sprintf（string format，mixed[string]）；</p>
<p>返回值：与函数printf作用类似，不同之处是他不将原需输出的字符串发送给浏览器，而是返回该字符串。</p>
<p><strong>Strchr</strong></p>
<p>函数描述：string strchr（string string ，string needle）；</p>
<p>说明：与函数strstr的作用相同。</p>
<p><strong>Strcmp</strong></p>
<p>函数描述：int strcmp(string str1,string str2);</p>
<p>说明：函数strcmp比较参数Str1与str2的大小，比较过程区分大小写。</p>
<p>返回值：如果str1大于str2，则函数strcmp返回1；如果str1小于str2，则返回-1；如果两者相等，则返回0。</p>
<p><strong>Strcspn</strong></p>
<p>函数描述：int strcspn(string str1 ,string str2);</p>
<p>返回值：从参数str1的首字符开始，不包括参数str 2中任意一个字符的最短字符串的长度。</p>
<p>（即str2在str1中的位置，返回的位置从0开始。）</p>
<p><strong>StripSlashes</strong></p>
<p>函数描述：string stripslashes(string string);</p>
<p>说明：删除参数string中的反斜杠字符。</p>
<p>返回值：返回经过上述操作的字符串。</p>
<p><strong>Strlen</strong></p>
<p>函数描述：int strlen(string string);</p>
<p>返回值：返回参数字符串string的长度。</p>
<p><strong>Strpos</strong></p>
<p>函数描述：int strops（string string ，string needle）；</p>
<p>说明：函数strpos中参数needle以整个字符串起作用。若参数needle为一个数字，则函数自动将其转化成整数并作为相对应的ASCII码使用。</p>
<p>返回值：函数strpos返回参数needle在字符串参数string中的最先位置，位置数从0开始。若在字符串string中不包含needle，则返回false（0）。</p>
<p><strong>Strrpos</strong></p>
<p>函数描述：int strrpos（string string ，string needle）；</p>
<p>说明：与函数strpos不同，函数strrpos中，参数needle中起作用的只是其首字符。若参数needle为一个数字，则函数自动将其转化成整数并作为相对应的ASCII码使用。</p>
<p>返回值：函数strrpos返回参数needle在字符串参数string中的最后位置，位置数从0开始。若在字符串string中不包含needle，则返回false（0）。</p>
<p><strong>Strrchr</strong></p>
<p>函数描述：string strrchr（string string ，string needle）；</p>
<p>说明：在函数strrchr中，参数needle中起作用的只是其首字符。若参数needle为一个数字，则函数自动将其转化成整数并作为相对应的ASCII码使用。</p>
<p>返回值：函数strrchr返回string中由最后一个needle字符开始及其之后的所有部分。若在字符串string中不包含needle，则返回false（0）。</p>
<p><strong>Strrev</strong></p>
<p>函数描述：string strrev（string string）；</p>
<p>返回值：函数strrev将参数string倒置并返回。</p>
<p><strong>StrStr</strong></p>
<p>函数描述：string strstr（string string ，string needle）；</p>
<p>说明：若参数needle为一个数字，则函数自动将其转化成整数并作为相对应的ASCII码使用。</p>
<p>返回值：函数strstr返回参数string中从参数needle开始及其之后的部分，包括参数needle。</p>
<p><strong>Strtok</strong></p>
<p>函数描述：string strtok(string str1,string str2);</p>
<p>返回值：返回参数str1中在参数str2首字母前的字符串。</p>
<p><strong>Strtolower</strong><strong>（&lt;-&gt; Strtoupper</strong><strong>）</strong></p>
<p>函数描述：string strtolower（string string）；</p>
<p>说明：jiang参数string中的大写字母替换成小写字母。</p>
<p>返回值：替换后的字符串。</p>
<p><strong>Strtr</strong></p>
<p>函数描述：string strtr(string string ,string from ,string to);</p>
<p>说明:函数strtr将参数string中字符from替换成字符to，若参数from和参数to的长度不同，则较长字符串中超过较短字符串长度的部分将被丢弃。</p>
<p>返回值：返回替换后的字符串。</p>
<p><strong>Substr</strong></p>
<p>函数描述：string substr（string string，int start，int [length]）；</p>
<p>说明：函数substr从参数string中的第start个字符开始，提取出一个长度为length的字符串。如果参数start是正数，则返回字符串将从参数string首部起第start个字符开始；若为负数，则返回字符串将从参数string尾部逆推的第start个字符开始。如果参数给出并为正，，则返回的是一个从start开始的长度为length的字符串；如果参数length给出且为负，则返回的字符串以正数第start位字符为首，以从参数string尾部开始逆推（-length）个字符为结束的字符串；若返回的字符串长度为负，则返回值为NULL。</p>
<p>返回值：返回所提取出的字符串。</p>
<p><strong>Trim</strong></p>
<p>函数描述：string trim（string string）；</p>
<p>说明：函数trim的作用等同于函数chop和ltrim共同对参数随同日内阁进行操作。</p>
<p>返回值：函数trim去除参数string首尾空格并返回新生成的字符串</p>
<p align="center"><strong>文件操作函数</strong></p>
<p><strong>Basename</strong></p>
<p>函数描述：string basename（string path）；</p>
<p>返回值：返回路径path底端的文件名。</p>
<p><strong>Chdir</strong></p>
<p>函数描述：int chdir（string directory）；</p>
<p>说明：函数chdir改变PHP脚本的默认路径。</p>
<p>返回值：如果改变成功，返回true（1），否则返回false（0）。</p>
<p><strong>Chgrp</strong></p>
<p>函数描述：int chgrp（string filename ，string group）；</p>
<p>说明：在UNIX中函数chgrp改变一个文件所在的组，但在Windows下该函数返回true（1）而无任何作用。</p>
<p>返回值：如果改变成功，返回true（1）；否则返回false（0）。</p>
<p><strong>Chmod</strong></p>
<p>函数描述：int chmod（string filename，int mode）；</p>
<p>说明：函数根参数mode给出的文件模式，对给出的文件设置UNIX权限。文件模式如下表：</p>
<p>返回值：如改变成功，返回true（1）；否则返回发false（0）。</p>
<p align="center"><strong>文件模式表</strong><strong></strong></p>
<table border="1" cellspacing="0" cellpadding="0" width="569">
<tbody>
<tr>
<td width="284" valign="top">
<p align="center"><strong>模 </strong><strong>式</strong></p>
</td>
<td width="284" valign="top">
<p align="center"><strong>描 </strong><strong>述</strong></p>
</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center">0</p>
</td>
<td width="284" valign="top">文件不许访问</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center">1</p>
</td>
<td width="284" valign="top">文件可执行</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center">2</p>
</td>
<td width="284" valign="top">文件可写</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="center">4</p>
</td>
<td width="284" valign="top">文件可读</td>
</tr>
</tbody>
</table>
<p><strong>Chown </strong></p>
<p>函数描述：int chown（string ，string user）；</p>
<p>说明：此函数改变文件所有者的名字。</p>
<p>返回值：如果改变成功，返回true（1）；否则，返回false（0）。</p>
<p><strong>Closedir</strong></p>
<p>函数描述：int closedir（int directory_handle）；</p>
<p>说明：在一个路径被函数opendir打开后，用此函数关闭该路径。</p>
<p>返回值：如果关闭成功，返回true（1）；否则，返回false（0）。</p>
<p><strong>Copy</strong></p>
<p>函数描述：int copy（string oldfilename ，string newfilename）；</p>
<p>说明：copy把由原参数oldfilename说明的文件复制到由目的参数newfilename说明的文件中。</p>
<p>返回值：如果复制成功，返回true（1）；否则，返回false（0）。</p>
<p><strong>Dir</strong></p>
<p>函数描述：obj dir（string directory）；</p>
<p>返回值：函数返回一个目录对象，该对象有两个属性：句柄和路径。句柄可被其他目录函数使用，路径是用来生成目录对象的字符串。如果出错，则返回false（0）。</p>
<p><strong>Fclose</strong></p>
<p>函数描述：int fclose(int file_handle);</p>
<p>说明：此函数关闭一个已打开的文件。参数file_handle为一个文件被打开时产生的句柄。</p>
<p>返回值：如果关闭成功，返回true（1）；否则，返回false（0）。</p>
<p><strong>Feof</strong></p>
<p>函数描述：int feof（int file_handle）;</p>
<p>说明：在读取文件时，PHP始终保持一个指向该文件末尾的指针。函数feof用以确定读取指针是否已到达文件末尾。</p>
<p>返回值：若文件读取指针达到文件末尾，函数feof返回ture（1）；否则返回false（0）。</p>
<p><strong>Fgetc</strong></p>
<p>函数描述：string fgetc（int file_handle）；</p>
<p>说明：参数file_handle是一个文件被打开时产生的句柄。</p>
<p>返回值：函数fgetc从一个已经对打开的文件中读取一个单个字符。如出错，则返回false（0）。</p>
<p><strong>Fgets</strong></p>
<p>函数描述：string fgets（int file_handle, int length）；</p>
<p>返回值：返回从文件中读取的字符串，文件由文件句柄file_handle指定，读取长度将根据length-1尽可能的读取字符，支行结束或文章末尾。若出错，则返回false（0）。</p>
<p><strong>Fgetss</strong></p>
<p>函数描述：string fgetss（int file_handle，int length）；</p>
<p>返回值：与fgets相类似，只是在返回字符串时，试着剥去HTML或PHP代码。</p>
<p>File</p>
<p>函数描述：array file（string filename）；</p>
<p>返回值：函数返回一个数组，数组的元素一次是文件的每一行，数组下标从开始。若出错，则返回false(0).</p>
<p><strong>File_exists</strong></p>
<p>函数描述：int file_exists(string filename);</p>
<p>说明：此函数用来确定文件是否存在。</p>
<p>返回值：若存在，返回true（1）；否则返回false（0）。</p>
<p><strong>Fileatime</strong></p>
<p>函数描述：int fileatime（string filename）；</p>
<p>返回值：以标准时间戳的格式，即从1971年1月1日起以秒计，返回最近改变文件的时间。在Windows下返回文件的生成时间。</p>
<p><strong>Filectime</strong></p>
<p>函数描述：int filectime（string filename）；</p>
<p>返回值：在UNIX下，函数filectime返回以标准时间戳的格式，即从1971年1月1日起以秒计，返回最近改变文件的时间。在Windows下返回文件的生成时间。</p>
<p><strong>Filegroup</strong></p>
<p>函数描述：int filegroup（string filename）；</p>
<p>返回值：在UNIX下，返回所给文件的组标志符，若出错则返回false（0）。在windows下总返回false（0）。</p>
<p><strong>Fileinode</strong></p>
<p>函数描述：int fileinode（string filename）；</p>
<p>返回值：在UNIX下，返回所给文件的inode，若出错则返回false（0）。在windows下总返回false（0）。</p>
<p><strong>Filemtime</strong></p>
<p>函数描述：int filemtime（string filename）；</p>
<p>返回值：函数filemtime返回以标准时间戳的格式，即从1971年1月1日起以秒计，返回最近改变文件的时间。该函数在UNIX和Windows下运行的结果一样。</p>
<p><strong>Fileowner</strong></p>
<p>函数描述：int fileowner（string filename）；</p>
<p>返回值：在UNIX下，函数返回文件所有者的用户标识符，若出错则返回false（0）。在windows下总返回false（0）。</p>
<p><strong>Fileperms</strong></p>
<p>函数描述：int fileperms（string filename）；</p>
<p>返回值：返回文件的许可权，若出错则返回false（0）。</p>
<p><strong>Filesize</strong></p>
<p>函数描述：int filesize（string filename）；</p>
<p>返回值：返回所给文件打消的字节数。</p>
<p><strong>Filetype</strong></p>
<p>函数描述：int filetype（string filename）；</p>
<p>返回值：函数filetype返回所给文件的类型作为描述的字符串，可能值为block,char,dir,fifo,file,link和unknown。</p>
<p><strong>Fopen</strong></p>
<p>函数描述：int fopen（string filename，string mode）；</p>
<p>说明：函数fopen根据参数filename和mode打开一个文件以便读写。若参数filename以"http://"或"ftp://"开始，则文件通过Internet用http或ftp协议打开；否则文件在本地系统内打开。</p>
<p>若模式带有"+"号，则为更新模式，它允许同时读和写；若字母"b"出现在模式的最后部分，则该文件被认为是二进制文件。（文件打开模式参见下表）</p>
<p align="center"><strong>文件打开模式表</strong><strong></strong></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="115">
<p align="center"><strong>模 </strong><strong>式</strong></p>
</td>
<td width="453" valign="top">
<p align="center"><strong>说 </strong><strong>明</strong></p>
</td>
</tr>
<tr>
<td width="115">
<p align="center"><strong>r</strong></p>
</td>
<td width="453" valign="top">以只读模式打开一个文件，并将文件内部指针指向文件开头</td>
</tr>
<tr>
<td width="115">
<p align="center"><strong>r+</strong></p>
</td>
<td width="453" valign="top">以可读可写模式打开一个文件，并将文件内部指针指向文件开头</td>
</tr>
<tr>
<td width="115">
<p align="center"><strong>w</strong></p>
</td>
<td width="453" valign="top">以只写模式打开一个文件，并将原文件内容清空，并将文件内部指针指向文件开头；若指定文件不存在，则创建一个名为filename的新文件。</td>
</tr>
<tr>
<td width="115">
<p align="center"><strong>w+</strong></p>
</td>
<td width="453" valign="top">以可读可写模式打开一个文件，并将原文件内容清空，并将文件内部指针指向文件开头；若指定文件不存在，则创建一个名为filename的新文件。</td>
</tr>
<tr>
<td width="115">
<p align="center"><strong>a</strong></p>
</td>
<td width="453" valign="top">以只写模式打开一个文件，并将文件内部指针指向文件末尾；若指定文件不存在，则创建一个名为filename的新文件。</td>
</tr>
<tr>
<td width="115">
<p align="center"><strong>a+</strong></p>
</td>
<td width="453" valign="top">以可读可写模式打开一个文件，并将文件内部指针指向文件末尾；若指定文件不存在，则创建一个名为filename的新文件。</td>
</tr>
</tbody>
</table>
<p><strong>Fpassthru</strong></p>
<p>函数描述：int fpassthru(int file_handle);</p>
<p>返回值：函数fpassthru向浏览器输出文件，完成后将文件关闭。若出错则返回发false（0）。</p>
<p><strong>Fputs</strong></p>
<p>函数描述：int fputs（int file_handle,string output）;</p>
<p>说明：函数fputs将数据写入一个打开的文件。</p>
<p>返回值:如果写入成功，返回true(1)；否则返回false（0）。</p>
<p><strong>Fread</strong></p>
<p>函数描述：string fread（int file_handle,string length）;</p>
<p>返回值：函数fread返回从指定文件中读取的字符串，当字符串长度等于参数length或文件结束时，读取结束。若读取失败，则返回false（0）。</p>
<p><strong>Fseek</strong></p>
<p>函数描述：int fseek（int file_handle,int offset）;</p>
<p>说明：函数fseek修改PHP中一个已打开文件的内部指针，其偏移量即距离文件头的字节数等于参数offset。</p>
<p>返回值：若修改成功，函数fseek返回0；否则返回-1。这需要读者注意。</p>
<p><strong>Ftell</strong></p>
<p>函数描述：int ftell（int file_handle）;</p>
<p>返回值：函数ftell返回PHP文件内部指针的偏移量。</p>
<p><strong>Fwrite</strong></p>
<p>函数描述：int fwrite（int file_handle, string string, int [length]）;</p>
<p>说明：函数fwrite将字符串string写入由文件句柄file_handle指定的文件。若可选参数length给出，则当字符串string结束或写入长度达length时写入结束。</p>
<p>返回值：若写入成功，返回true(1);否则返回false（0）。</p>
<p><strong> </strong></p>
<p><strong>提示：</strong>以字符"gz"开始的库函数，用于对压缩文件的操作。</p>
<p><strong>Gzclose</strong></p>
<p>函数描述：int gzclose(int file_handle);</p>
<p>说明：关闭由gzopen打开的文件。</p>
<p>返回值：若关闭成功返回true（1）；否则返回false（0）。</p>
<p>（Gzof、Gzfile、Gzgetc、Gzgets、Gzgetss、Gzopen、Gzpassthru、Gzputs、Gzrewind、Gzseek、Gztell）与前面的文件操作函数类似。</p>
<p><strong>Is_dir</strong></p>
<p>函数描述：int is_dir(string filename);</p>
<p>返回值：若给出的参数filename是一个目录，则函数is_dir返回true（1）；否则返回false（0）。</p>
<p><strong>Is_executable</strong></p>
<p>函数描述：int is_executable（string filename）；</p>
<p>返回值：如果文件存在且可执行，返回true（1）；否则返回false（0）。</p>
<p><strong>Is_file</strong></p>
<p>函数描述：int is_file(string filename);</p>
<p>返回值：如果参数filename]所指的文件存在且是一个正常的文件，则函数is_file返回true（1）；否则返回false（0）。</p>
<p><strong>Is_link</strong></p>
<p>函数描述：int is_link(string dilename);</p>
<p>返回值：如果参数filename是符号连接，则函数is_link返回true（1）；否则返回false（0）。</p>
<p><strong>Is_readable</strong></p>
<p>函数描述：int is_readable(string filename);</p>
<p>返回值：如果文件存在且可读，则函数is_readable返回true(1);否则返回false（0）。在UNIX中，取决于文件的许可权，在Windows中函数的返回值总为true。</p>
<p><strong>Is_writeable</strong></p>
<p>函数描述：int is_writeable(string filename);</p>
<p>返回值：如果文件存在且可写，则函数is_writeable返回true（1）；否则返回false（0）。</p>
<p><strong>Link</strong></p>
<p>函数描述：int link(string source,string destination);</p>
<p>说明：函数link生成一个硬链接。在Windows中，该函数不起任何作用，也不返回任何值。</p>
<p><strong>Mkdir</strong></p>
<p>函数描述：int mkdir（string directory，int mode）；</p>
<p>说明：函数mkdir用所给的名字创建一个新的目录，许可权根据模式参数进行设置。</p>
<p>返回值：目录创建成功，返回true(1);否则返回false（0）。</p>
<p><strong>Opendir</strong></p>
<p>函数描述：int opendir（string directory）；</p>
<p>返回值：函数opendir根据所给目录名directory返回一个目录句柄。</p>
<p><strong>Pclose</strong></p>
<p>函数描述：int pclose（int file_handle）；</p>
<p>说明：关闭由popen函数打开的文件流。</p>
<p><strong>Popen</strong></p>
<p>函数描述：int popen（string command，string mode）；</p>
<p>说明：函数popen打开一个通向正在执行的命令的管道，该管道可读可写。</p>
<p>返回值：函数popen返回一个文件句柄。</p>
<p><strong>Readdir</strong></p>
<p>函数描述：string readdir（int directory_handle）；</p>
<p>返回值：函数readdir返回由目录句柄directory_handle指定目录中的下一个文件的文件名。</p>
<p><strong>Readfile</strong></p>
<p>函数描述：int readfile（string filename）；</p>
<p>说明：用函数readfile读取所给的文件并直接发送给浏览器。若参数filename是以<a href="http:///">http://</a>或ftp://开头的，则相应地用http或ftp协议读取文件。</p>
<p><strong>Readgzfile</strong></p>
<p>与readfile类似，只是他作用于压缩文件。</p>
<p><strong>Readlink</strong></p>
<p>函数描述：string readlink（string filename）；</p>
<p>返回值：函数readlink返回一个符号链接所指的路径；若出错，则返回false（0）。</p>
<p><strong>Rename</strong></p>
<p>函数描述：int rename（string old_name,string new_name）；</p>
<p>说明：函数rename将参数old_name指定的文件名改变为由参数new_name指定的文件名。</p>
<p>返回值：若改变成功，返回true（1）；否则返回false（0）。</p>
<p><strong>Rewind</strong></p>
<p>函数描述：int rewind（int file_handle）;</p>
<p>说明：函数rewind将PHP的内部文件指针移到文件头。</p>
<p><strong>Rewinddir</strong></p>
<p>函数描述：int rewinddir（int directory_handle）;</p>
<p>说明：函数rewinddir将PHP的内部指针重置到一目录列表的开头。</p>
<p>返回值：若重置成功，则函数rewinddir返回true（1）；否则返回false（0）。</p>
<p><strong>Rmdir</strong></p>
<p>函数描述：int rmdir（string directory）；</p>
<p>说明：利用函数rmdir可以删除一个目录。</p>
<p>返回值：若删除成功，则函数rmdir返回true（1）；否则返回false（0）。</p>
<p><strong>Stat</strong></p>
<p>函数描述：array stat（string filename）；</p>
<p>说明：函数stat执行C语言中的stat函数并返回一个由13个元素的数组。元素如表所示：</p>
<p align="left">返回值：函数stat返回生成的数组。</p>
<p align="center"><strong> </strong></p>
<p align="center"><strong>函数stat</strong><strong>的返回数组元素表</strong></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="139" valign="top">
<p align="center"><strong>元 </strong><strong>素 </strong><strong>下 </strong><strong>标</strong></p>
</td>
<td width="429" valign="top">
<p align="center"><strong>元 </strong><strong>素 </strong><strong>内 </strong><strong>容</strong></p>
</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>0</strong></p>
</td>
<td width="429" valign="top">文件所在设备或驱动器字母</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>1</strong></p>
</td>
<td width="429" valign="top">索引节点</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>2</strong></p>
</td>
<td width="429" valign="top">文件模式</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>3</strong></p>
</td>
<td width="429" valign="top">链接数</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>4</strong></p>
</td>
<td width="429" valign="top">用户</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>5</strong></p>
</td>
<td width="429" valign="top">文件所在组</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>6</strong></p>
</td>
<td width="429" valign="top">设备类型或驱动器字母</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>7</strong></p>
</td>
<td width="429" valign="top">文件大小</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>8</strong></p>
</td>
<td width="429" valign="top">文件的最后访问时间</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>9</strong></p>
</td>
<td width="429" valign="top">文件的最后修改时间</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>10</strong></p>
</td>
<td width="429" valign="top">文件的最后改变或生成时间</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>11</strong></p>
</td>
<td width="429" valign="top">块大小</td>
</tr>
<tr>
<td width="139" valign="top">
<p align="center"><strong>12</strong></p>
</td>
<td width="429" valign="top">块数目</td>
</tr>
</tbody>
</table>
<p><strong>Symlink</strong></p>
<p>函数描述：int symlink（string source，string destination）;</p>
<p>说明：函数symlink用目的参数中的名字创建一个符号链接到源参数。</p>
<p>返回值：若创建成功，返回true(1);否则返回false（0）。</p>
<p><strong>Touch</strong></p>
<p>函数描述：int touch（string filename，string [time]）；</p>
<p>说明：函数将文件的最近修改时间设置为给出的时间time，time为从1970年1月1日起的秒数。若time默认，则使用当前时间。</p>
<p><strong>Umask</strong></p>
<p>函数描述：int umask（int [umask]）；</p>
<p>说明：函数返回文件创建时赋予的默认的许可权。</p>
<p>返回值：若给出了可选参数umask，则函数返回参数umask与0777的逻辑与。在Windows下，该函数不起任何作用，且返回false（0）。</p>
<p><strong>Unlink</strong></p>
<p>函数描述：int unlink（string filename）；</p>
<p>说明：函数unlink永久删除一个文件。</p>
<p>返回值：若删除成功，则函数unlink返回true（1）；否则返回false（0）。</p>
<p align="center"><strong>其他函数</strong><strong></strong></p>
<p><strong>Include</strong></p>
<p>函数描述：include （string filename）；</p>
<p>说明：函数include使PHP编译器打开并执行所给的文件。该文件被看作普通的PHP脚本。也可以通过URL以http://或ftp://开头来指明文件。</p>
<p>返回值：无。</p>
<p><strong>Require</strong></p>
<p>函数描述：require （string filename）；</p>
<p>说明：函数require使PHP编译器打开并执行所给的文件。该文件被看作普通的PHP脚本。也可以通过URL以http://或ftp://开头来指明文件。</p>
<p>返回值：无。</p>
<p>从表面上看，函数include和require的作用是相同的，我们可以用它们将一些包含已编写代码的文件引入到PHP程序中。在这些文件中，主要存储需要重复使用的常量、变量声明和一些函数的声明和定义。函数include和require的使用，可以使复杂的PHP程序变得简洁明了。</p>
<p>但在实际执行过程中，这两个函数有着很大的差别。函数require通常放在PHP程序的最前面，PHP程序开始执行，就会先读入require所指定的文件，将它变成PHP程序的一部分。常用的自定义函数可以通过这种方法引入PHP程序。而函数include通常放在PHP程序的循环结构中，每次程序运行include语句，就将include所指定的文件引入PHP程序执行一遍。</p>
<p><strong>Header</strong></p>
<p>函数描述：int header(string http_header);</p>
<p>说明：函数hader发送一个http头标给浏览器，需要注意的是，函数必须将任何输出发送给浏览器之前调用。</p>
<p>返回值：如果发送成功，函数header返回true（1）；否则返回false（0）。</p>
<p><strong>Getenv</strong></p>
<p>函数描述：string getenv(string variable);</p>
<p>返回值：函数getenv返回所给出的环境变量值；若出错，则返回false（0）。</p>
<p><strong>Putenv</strong></p>
<p>函数描述：putenv（string variable）；</p>
<p>说明：函数putenv设置一个环境变量的值。</p>
<p><strong>Getallheaders</strong></p>
<p>函数描述：array getallheader();</p>
<p>返回值：函数getallheader返回在服务器和浏览器之间交换的所有头，其中有些将被转换为环境变量。</p>
<p><strong>Setcookie</strong></p>
<p>函数描述：int setcookie（string name,string value,int expire ,string path,string domain,int secure）;</p>
<p>返回值：如果设置成功，返回true（1）；否则返回false（0）。</p>
<p><strong>Gethostbyaddr</strong></p>
<p>函数描述：string gethostbyaddr（string ip_address）;</p>
<p>返回值：函数gethostbyaddr返回由IP地址指定的主机名。</p>
<p><strong>Gethostbyname</strong></p>
<p>函数描述：string gethostbyname（string hostname）；</p>
<p>返回值：函数gethostbyname返回由主机名hostname指定的主机的IP地址。</p>
<p><strong>Gethostbynamel</strong></p>
<p>函数描述：array Gethostbynamel（string hostname）；</p>
<p>返回值：函数Gethostbynamel返回由主机名hostname指定的主机的IP地址列表。</p>
<p align="center"><strong>PHP</strong><strong>中的环境变量</strong><strong></strong></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="175" valign="top">
<p align="center"><strong>变 </strong><strong>量 </strong><strong>名</strong></p>
</td>
<td width="393" valign="top">
<p align="center"><strong>描 </strong><strong>述</strong></p>
</td>
</tr>
<tr>
<td width="175" valign="top"><strong>AUTH_TYPE</strong></td>
<td width="393" valign="top">该变量提供用来访问脚本使用的认证协议（需本地服务器支持）</td>
</tr>
<tr>
<td width="175" valign="top"><strong>GETEWAY_INTERFACE</strong></td>
<td width="393" valign="top">本地服务器支持的CGI版本</td>
</tr>
<tr>
<td width="175" valign="top"><strong>HTTP_USER_AGENT</strong></td>
<td width="393" valign="top">用户浏览器的类型和版本</td>
</tr>
<tr>
<td width="175"><strong>HTTP_FROM</strong></td>
<td width="393" valign="top">用户的E-mail地址（在給HTML表单提供了默认值的情况下才能使用）</td>
</tr>
<tr>
<td width="175" valign="top"><strong>PATH_INFO</strong></td>
<td width="393" valign="top">调用脚本的HTML请求的路径信息</td>
</tr>
<tr>
<td width="175" valign="top"><strong>REMOTE_ADDR</strong></td>
<td width="393" valign="top">用户的IP地址</td>
</tr>
<tr>
<td width="175" valign="top"><strong>REMOTE_HOST</strong></td>
<td width="393" valign="top">用户所使用的计算机的域名</td>
</tr>
<tr>
<td width="175" valign="top"><strong>SCRIPT_NAME</strong></td>
<td width="393" valign="top">脚本的路径名</td>
</tr>
<tr>
<td width="175" valign="top"><strong>SERVER_NAME</strong></td>
<td width="393" valign="top">服务器的主机名</td>
</tr>
<tr>
<td width="175" valign="top"><strong>SERVER_PORT</strong></td>
<td width="393" valign="top">本地web服务器监听的端口号</td>
</tr>
<tr>
<td width="175" valign="top"><strong>SERVER_PROTOCOL</strong></td>
<td width="393" valign="top">服务器使用的网络协议的版本</td>
</tr>
<tr>
<td width="175" valign="top"><strong>SERVER_SOFTWARE</strong></td>
<td width="393" valign="top">Web服务器的名称和版本</td>
</tr>
</tbody>
</table>
<p align="center"><strong>PHP</strong><strong>数据库函数(</strong><strong>基于MySQL)</strong></p>
<p>PHP关于MySQL数据库的函数有几十个，这里只介绍常用的一些，目的是能够快速上手。如果实践中需要更多的库函数，可以翻阅PHP函数手册。</p>
<p><strong>Mysql_connect</strong></p>
<p>函数描述：int mysql_connect(string [hostname] ,string [username] , string [password]);</p>
<p>说明：mysql_connect是最常用一个函数，它用来建立和指定主机上的Mysql数据库的连接。三个参数均是可选选取项，默认值分别是：localhost、服务器进程的所有者及空串。其中，hostname可包含端口号，可写为：hostname:port。</p>
<p>在该PHP脚本运行结束时，连接被自动关闭，当然也可经用mysql_close来提前结束该连接。如果想建成立永久性连接，可使用函数mysql_pconnect。除了这一点外，这个函数是和mysql_connect完全相同。</p>
<p>返回值：连接成功后会返回一个MySQL连接标识符，失败时返回 false。</p>
<p><strong>mysql_select_db</strong></p>
<p>函数描述： int mysql_select_db(string database_name , int [link_identifier]);</p>
<p>说明：mysql_select_db用来根据连接标识符在该数据库服务器上选取数据库作为当前的数据库。如果不特别声明连接标识符，则默认为是上一次打开的连接。该函数使用前必须调用Mysql_connect函数。</p>
<p>返回值：选取成功后返回true,失败时返回false。</p>
<p><strong>Mysql_query</strong></p>
<p>函数描述：int mysql_query(string query ,int [link_identifier]);</p>
<p>说明：mysql_query用来根据连接标识符向该数据库服务器的当前数据库发送查询，如果连接标识符默认，则默认为是上一次打开的连接。Query为标准SQL语句。</p>
<p>返回值：成功后返回一个结果标识符，失败时返回false。</p>
<p><strong>Mysql_fetch_row</strong></p>
<p>函数描述：int mysql_fetch_row(int result);</p>
<p>说明：mysql_fetch_row用来查询结果的一行保存至数组，该数组下标从0开始，每一个数组元素对应一个域。通过循环，可以将查询结果全部获得。</p>
<p>返回值：返回下行的所有域值，并将其保存至一个数组中，没有行时返回false。</p>
<p><strong>Mysql_fetch_array</strong></p>
<p>函数描述：array int result);</p>
<p>说明：mysql_fetch_array和mysql_fetch_row功能基本相同，只不过它除了可以用从0开始的偏移量作索引，还可以用域名作索引。</p>
<p>返回值返回下一行的所有域值，并将其保存至一个数组中，没有行时返回false。</p>
<p><strong>Mysql_num_rows</strong></p>
<p>函数描述：int (string result);</p>
<p>说明：mysql_num_rows用于计算查询结果中所得行的数目。</p>
<p>返回值：返回查询结果中所得行的数目。</p>
<p><strong>Mysql_result</strong></p>
<p>函数描述：int mysql_result(int result , int row , mixed field);</p>
<p>说明：mysql_resultet 用于获取结果集中指定域的数据。Field可以是一个偏移量，也可以是列名，如果列有别名，还可以用这外别名。</p>
<p>返回值：返回结果集中指定行、指定偏听偏信移量的数据。</p>
<p><strong>Mysql_close</strong></p>
<p>函数描述：int mysql_close(int [link_identifier]);</p>
<p>说明：mysql_close用于关闭当前与数据库服务器的连接。</p>
<p>返回值：成功后返回true，失败时返回false。</p>
<p align="center"><strong>Session</strong><strong>函数</strong></p>
<p><strong>Session_start</strong></p>
<p>函数描述：boolean session_start(void);</p>
<p>功能说明：session_start函数的功能是初始化一个新的session,如果已经存在一个为该用户服务的session，则连接原有的session。</p>
<p>参数说明：无。</p>
<p>返回值：逻辑类型变量，且值永远为真。</p>
<p><strong>Session_destroy</strong></p>
<p>函数描述：boolean session_destroy(void);</p>
<p>功能说明session_destroy结束原有的session 。</p>
<p>参数说明：无。</p>
<p>返回值：逻辑类型变量，且值永远为真。</p>
<p><strong>Session­_register</strong></p>
<p>函数描述：boolean session_register(string name);</p>
<p>功能说明：在session中增加一个变量。</p>
<p>参数说明："string name"变量名。</p>
<p>返回值：逻辑类型变量。操作成功返回真值。</p>
<p><strong>Session_unregister</strong></p>
<p>函数说明：boolean session_unregister(string name);</p>
<p>功能说明：在session中删除一个变量。</p>
<p>参数说明："string name"变量名。</p>
<p>返回值：逻辑类型变量。操作成功返回真值。</p>
<p><strong>Session_is_registered</strong></p>
<p>函数描述：boolean session_is_registered(string name);</p>
<p>功能说明：检查session中是否存在所指定的变量。</p>
<p>参数说明："string name"变量名。</p>
<p>返回值：逻辑类型变量。</p>
<p><strong>Session_encode</strong></p>
<p>函数描述：boolean session_encode(void);</p>
<p>功能说明：session_encode函数对当前的session资料编码，PHP4采用哈希编码。</p>
<p>参数说明：无。</p>
<p>返回值：逻辑类型变量。编码成功则返回真值。</p>
<p><strong>Session_decode</strong></p>
<p>函数描述：boolean session_decode(string data);</p>
<p>功能说明：session_decode可以编过码的资料解码。</p>
<p>参数说明："string data"需要解码的资料。</p>
<p>返回值：逻辑类型变量。</p>
<div  class="related_post_title">More:</div><ul class="related_post"><li><a href="http://imwewe.com/2007/02/%e3%80%8a%e8%b6%8a%e7%8b%b1%e3%80%8b%e4%b8%adt-bag%e5%90%ab%e4%b9%89%e7%9a%84%e6%ad%a3%e8%a7%a3.html" title="《越狱》中T-bag含义的正解">《越狱》中T-bag含义的正解</a></li><li><a href="http://imwewe.com/2007/06/mp3.html" title="耳朵的旅程">耳朵的旅程</a></li><li><a href="http://imwewe.com/2007/04/nba-live-2007-in-linux.html" title="nba live 2007 in linux">nba live 2007 in linux</a></li><li><a href="http://imwewe.com/2011/11/hangzhou-botanical-garden.html" title="一叶知秋">一叶知秋</a></li><li><a href="http://imwewe.com/2009/04/imwewe-tweets-on-2009-04-24.html" title="imwewe tweets on 2009-04-24">imwewe tweets on 2009-04-24</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://imwewe.com/2009/04/php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

