php函数 要看的

php函数 要看的<br /> strtoupper<br /> strtoupper -- Make a string uppercase<br /> <br /> strtolower<br /> strtolower -- Make a string lowercase<br /> <br /> is_file<br /> is_file -- 判断给定文件名是否为一个正常的文件<br /> <br /> dir<br /> dir -- directory 类<br /> &lt;?php<br /> $d = dir(&quot;C:\wamp\www\lt\upload&quot;);<br /> echo &quot;Handle: &quot; . $d-&gt;handle . &quot;&lt;br&gt;&quot;;<br /> echo &quot;Path: &quot; . $d-&gt;path . &quot;&lt;br&gt;&quot;;<br /> while (false !== ($entry = $d-&gt;read())) {<br /> echo $entry.&quot;&lt;br&gt;&quot;;<br /> }<br /> $d-&gt;close();<br /> ?&gt;<br /> <br /> trim<br /> trim -- Strip whitespace (or other characters) from the beginning and end of a string <br /> &lt;?php<br /> $text = &quot;\t\tThese are a few words :) ... &quot;;<br /> echo trim($text); // &quot;These are a few words :) ...&quot;<br /> echo trim($text, &quot; \t.&quot;); // &quot;These are a few words :)&quot;<br /> // trim the ASCII control characters at the beginning and end of $binary<br /> // (from 0 to 31 inclusive)<br /> $clean = trim($binary, &quot;\x00..\x1F&quot;);<br /> ?&gt; <br /> <br /> rmdir<br /> rmdir -- 删除目录<br /> <br /> unlink<br /> unlink -- 删除文件<br /> <br /> unset<br /> unset -- 释放给定的变量<br /> 例子 1. unset() 示例<br /> &lt;?php<br /> // 销毁单个变量<br /> unset ($foo);<br /> // 销毁单个数组元素<br /> unset ($bar['quux']);<br /> // 销毁一个以上的变量<br /> unset ($foo1, $foo2, $foo3);<br /> ?&gt; <br /> <br /> file_get_contents<br /> file_get_contents -- 将整个文件读入一个字符串<br /> file_put_contents<br /> file_put_contents -- 将一个字符串写入文件<br /> <br /> touch<br /> touch -- 设定文件的访问和修改时间<br /> &lt;?php<br /> if (touch($FileName)) {<br /> echo &quot;$FileName modification time has been changed to present time&quot;;<br /> } else {<br /> echo &quot;Sorry, could not change modification time of $FileName&quot;;<br /> }<br /> ?&gt; <br /> <br /> fclose<br /> fclose -- 关闭一个已打开的文件指针<br /> <br /> fopen<br /> fopen -- 打开文件或者 URL<br /> <br /> fwrite<br /> fwrite -- 写入文件(可安全用于二进制文件)<br /> <br /> flock<br /> flock -- 轻便的咨询文件锁定<br /> 例子 1. flock() 例子<br /> <br /> &lt;?php<br /> <br /> $fp = fopen(&quot;/tmp/lock.txt&quot;, &quot;w+&quot;);<br /> <br /> if (flock($fp, LOCK_EX)) { // 进行排它型锁定<br /> fwrite($fp, &quot;Write something here\n&quot;);<br /> flock($fp, LOCK_UN); // 释放锁定<br /> } else {<br /> echo &quot;Couldn't lock the file !&quot;;<br /> }<br /> fclose($fp);<br /> ?&gt; <br /> <br /> count<br /> count -- 计算数组中的单元数目或对象中的属性个数<br /> <br /> parse_url<br /> parse_url -- 解析 URL,返回其组成部分<br /> 描述<br /> array parse_url ( string url )<br /> 此函数返回一个关联数组,包含现有 URL 的各种组成部分。如果缺少了其中的某一个,则不会为这个组成部分创建数组项。组成部分为: <br /> scheme - 如 http <br /> host<br /> port <br /> user <br /> pass <br /> path <br /> query - 在问号 ? 之后 <br /> fragment - 在散列符号 # 之后 <br /> 此函数并 不 意味着给定的 URL 是合法的,它只是将上方列表中的各部分分开。parse_url() 可接受不完整的 URL,并尽量将其解析正确。 <br /> 注: 此函数对相对路径的 URL 不起作用。 <br /> 例子 1. parse_url() 示例<br /> $ php -r 'print_r(parse_url(&quot;http://username:password@hostname/path?arg=value#anchor&quot;));'<br /> Array<br /> (<br /> [scheme] =&gt; http<br /> [host] =&gt; hostname<br /> [user] =&gt; username<br /> [pass] =&gt; password<br /> [path] =&gt; /path<br /> [query] =&gt; arg=value<br /> [fragment] =&gt; anchor<br /> )<br /> $ php -r 'print_r(parse_url(&quot;http://invalid_host..name/&quot;));'<br /> Array<br /> (<br /> [scheme] =&gt; http<br /> [host] =&gt; invalid_host..name<br /> [path] =&gt; /<br /> )<br /> <br /> get_magic_quotes_gpc<br /> get_magic_quotes_gpc -- Gets the current configuration setting of magic quotes gpc <br /> 例子 1. get_magic_quotes_gpc() example<br /> <br /> &lt;?php<br /> echo get_magic_quotes_gpc(); // 1<br /> echo $_POST['lastname']; // O\'reilly<br /> echo addslashes($_POST['lastname']); // O\\\'reilly<br /> if (!get_magic_quotes_gpc()) {<br /> $lastname = addslashes($_POST['lastname']);<br /> } else {<br /> $lastname = $_POST['lastname'];<br /> }<br /> echo $lastname; // O\'reilly<br /> $sql = &quot;INSERT INTO lastnames (lastname) VALUES ('$lastname')&quot;;<br /> ?&gt; <br /> <br /> dirname<br /> dirname -- 返回路径中的目录部分<br /> <br /> htmlspecialchars<br /> htmlspecialchars -- Convert special characters to HTML entities <br /> <br /> rawurlencode<br /> rawurlencode -- 按照 RFC 1738 对 URL 进行编码<br /> <br /> rawurldecode<br /> (PHP 3, PHP 4, PHP 5)<br /> <br /> rawurldecode -- 对已编码的 URL 字符串进行解码<br /> 描述<br /> string rawurldecode ( string str )<br /> 返回字符串,此字符串中百分号(%)后跟两位十六进制数的序列都将被替换成原义字符。 <br /> 例子 1. rawurldecode() 示例<br /> &lt;?php<br /> echo rawurldecode('foo%20bar%40baz'); // foo bar@baz<br /> ?&gt; <br /> <br /> is_numeric<br /> is_numeric -- 检测变量是否为数字或数字字符串 <br /> <br /> uniqid<br /> uniqid -- Generate a unique ID<br /> &lt;?php<br /> // no prefix<br /> $token = md5(uniqid());<br /> <br /> // better, difficult to guess<br /> $better_token = md5(uniqid(rand(), true));<br /> ?&gt; <br /> <br /> strtotime<br /> strtotime -- 将任何英文文本的日期时间描述解析为 Unix 时间戳<br /> 例子 1. strtotime() 例子<br /> <br /> &lt;?php<br /> echo strtotime(&quot;now&quot;), &quot;\n&quot;;<br /> echo strtotime(&quot;10 September 2000&quot;), &quot;\n&quot;;<br /> echo strtotime(&quot;+1 day&quot;), &quot;\n&quot;;<br /> echo strtotime(&quot;+1 week&quot;), &quot;\n&quot;;<br /> echo strtotime(&quot;+1 week 2 days 4 hours 2 seconds&quot;), &quot;\n&quot;;<br /> echo strtotime(&quot;next Thursday&quot;), &quot;\n&quot;;<br /> echo strtotime(&quot;last Monday&quot;), &quot;\n&quot;;<br /> ?&gt; <br /> <br /> round<br /> round -- 对浮点数进行四舍五入<br /> <br />
RangeTime:0.008654s
RangeMem:211.51 KB
返回顶部 留言