﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-分享ｊａｖａ带来的快乐-文章分类-php</title><link>http://www.blogjava.net/lyjjq/category/47552.html</link><description>我喜欢ｊａｖａ新东西</description><language>zh-cn</language><lastBuildDate>Wed, 21 Nov 2012 15:59:57 GMT</lastBuildDate><pubDate>Wed, 21 Nov 2012 15:59:57 GMT</pubDate><ttl>60</ttl><item><title>PHP CURL</title><link>http://www.blogjava.net/lyjjq/articles/391506.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Sat, 17 Nov 2012 12:42:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/391506.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/391506.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/391506.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/391506.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/391506.html</trackback:ping><description><![CDATA[<p>使用PHP的cURL库可以简单和有效地去抓网页。你只需要运行一个脚本，然后分析一下你所抓取的网页，然后就可以以程序的方式得到你想要的数据了。无论是你想从从一个链接上取部分数据，或是取一个XML文件并把其导入数据库，那怕就是简单的获取网页内容，cURL <br />是一个功能强大的PHP库。</p><br /><p>PHP中的CURL函数库（Client URL Library Function）</p><br /><p>curl_close &#8212; 关闭一个curl会话<br />curl_copy_handle &#8212; <br />拷贝一个curl连接资源的所有内容和参数<br />curl_errno &#8212; 返回一个包含当前会话错误信息的数字编号<br />curl_error &#8212; <br />返回一个包含当前会话错误信息的字符串<br />curl_exec &#8212; 执行一个curl会话<br />curl_getinfo &#8212; <br />获取一个curl连接资源句柄的信息<br />curl_init &#8212; 初始化一个curl会话<br />curl_multi_add_handle &#8212; <br />向curl批处理会话中添加单独的curl句柄资源<br />curl_multi_close &#8212; 关闭一个批处理句柄资源<br />curl_multi_exec &#8212; <br />解析一个curl批处理句柄<br />curl_multi_getcontent &#8212; 返回获取的输出的文本流<br />curl_multi_info_read &#8212; <br />获取当前解析的curl的相关传输信息<br />curl_multi_init &#8212; <br />初始化一个curl批处理句柄资源<br />curl_multi_remove_handle &#8212; <br />移除curl批处理句柄资源中的某个句柄资源<br />curl_multi_select &#8212; Get all the sockets associated with <br />the cURL extension, which can then be "selected"<br />curl_setopt_array &#8212; <br />以数组的形式为一个curl设置会话参数<br />curl_setopt &#8212; 为一个curl设置会话参数<br />curl_version &#8212; <br />获取curl相关的版本信息</p><br /><p>curl_init()函数的作用初始化一个curl会话，curl_init()函数唯一的一个参数是可选的，表示一个url地址。<br />curl_exec()函数的作用是执行一个curl会话，唯一的参数是curl_init()函数返回的句柄。<br />curl_close()函数的作用是关闭一个curl会话，唯一的参数是curl_init()函数返回的句柄。</p><br /><p>例子一: 基本例子<br />基本例子<br />﹤?php<br />// 初始化一个 cURL 对象<br />$curl = curl_init();</p><br /><p>// 设置你需要抓取的URL<br />curl_setopt($curl, CURLOPT_URL, 'http://www.cmx8.cn');</p><br /><p>// 设置header<br />curl_setopt($curl, CURLOPT_HEADER, 1);</p><br /><p>// 设置cURL 参数，要求结果保存到字符串中还是输出到屏幕上。<br />curl_setopt($curl, <br />CURLOPT_RETURNTRANSFER, 1);</p><br /><p>// 运行cURL，请求网页<br />$data = curl_exec($curl);</p><br /><p>// 关闭URL请求<br />curl_close($curl);</p><br /><p>// 显示获得的数据<br />var_dump($data);</p><br /><p>?&gt;</p><br /><p>例子二: POST数据</p><br /><p>sendSMS.php，其可以接受两个表单域，一个是电话号码，一个是短信内容。<br />POST数据<br />﹤?php<br />$phoneNumber　=　'13812345678';<br />$message　=　'This　message　was　generated　by　curl　and　php';<br />$curlPost　=　'pNUMBER='　.　urlencode($phoneNumber)　.　'&amp;MESSAGE='　.　urlencode($message)　.　'&amp;SUBMIT=Send';<br />$ch　=　curl_init();<br />curl_setopt($ch,　CURLOPT_URL,　'http://www.lxvoip.com/sendSMS.php');<br />curl_setopt($ch,　CURLOPT_HEADER,　1);<br />curl_setopt($ch,　CURLOPT_RETURNTRANSFER,　1);<br />curl_setopt($ch,　CURLOPT_POST,　1);<br />curl_setopt($ch,　CURLOPT_POSTFIELDS,　$curlPost);<br />$data　=　curl_exec();<br />curl_close($ch);<br />?﹥</p><br /><p>例子三:使用代理服务器<br />使用代理服务器<br />﹤?php　<br />$ch　=　curl_init();<br />curl_setopt($ch,　CURLOPT_URL,　'http://www.cmx8.cn');<br />curl_setopt($ch,　CURLOPT_HEADER,　1);<br />curl_setopt($ch,　CURLOPT_RETURNTRANSFER,　1);<br />curl_setopt($ch,　CURLOPT_HTTPPROXYTUNNEL,　1);<br />curl_setopt($ch,　CURLOPT_PROXY,　'proxy.lxvoip.com:1080');<br />curl_setopt($ch,　CURLOPT_PROXYUSERPWD,　'user:password');<br />$data　=　curl_exec();<br />curl_close($ch);<br />?﹥</p><br /><p>例子四: 模拟登录</p><br /><p>Curl 模拟登录 discuz 程序,适合DZ7.0,将username改成你的用户名,userpass改成你的密码就可以了.<br />Curl 模拟登录 <br />discuz <br />程序<br />&lt;?php <wbr> <wbr> <wbr><br /> <wbr> <wbr><br /> <wbr> <wbr><br />!extension_loaded('curl') <br />&amp;&amp; die('The curl extension is not <br />loaded.'); <wbr> <wbr> <wbr><br /> <wbr> <wbr><br />$discuz_url = <br />'http://www.lxvoip.com';//论坛地址 <wbr> <wbr> <wbr><br />$login_url = $discuz_url <br />.'/logging.php?action=login';//登录页地址 <wbr> <wbr> <wbr><br />$get_url = $discuz_url <br />.'/my.php?item=threads'; <br />//我的帖子 <wbr> <wbr> <wbr><br /> <wbr> <wbr><br />$post_fields = <br />array(); <wbr> <wbr> <wbr><br />//以下两项不需要修改 <wbr> <wbr> <wbr><br />$post_fields['loginfield'] <br />= 'username'; <wbr> <wbr> <wbr><br />$post_fields['loginsubmit'] = <br />'true'; <wbr> <wbr> <wbr><br />//用户名和密码，必须填写 <wbr> <wbr> <wbr><br />$post_fields['username'] <br />= 'lxvoip'; <wbr> <wbr> <wbr><br />$post_fields['password'] = <br />'88888888'; <wbr> <wbr> <wbr><br />//安全提问 <wbr> <wbr> <wbr><br />$post_fields['questionid'] <br />= 0; <wbr> <wbr> <wbr><br />$post_fields['answer'] = <br />''; <wbr> <wbr> <wbr><br /><a>//@todo</a>验证码 <wbr> <wbr> <wbr><br />$post_fields['seccodeverify'] <br />= <br />''; <wbr> <wbr> <wbr><br /> <wbr> <wbr><br />//获取表单FORMHASH <wbr> <wbr> <wbr><br />$ch <br />= curl_init($login_url); <wbr> <wbr> <wbr><br />curl_setopt($ch, CURLOPT_HEADER, <br />0); <wbr> <wbr> <wbr><br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, <br />1); <wbr> <wbr> <wbr><br />$contents = <br />curl_exec($ch); <wbr> <wbr> <wbr><br />curl_close($ch); <wbr> <wbr> <wbr><br />preg_match('/&lt;input\s*type="hidden"\s*name="formhash"\s*value="(.*?)"\s*\/&gt;/i', <br />$contents, $matches); <wbr> <wbr> <wbr><br />if(!empty($matches)) <br />{ <wbr> <wbr> <wbr><br /> <wbr> <wbr> <wbr> $formhash = <br />$matches[1]; <wbr> <wbr> <wbr><br />} else <br />{ <wbr> <wbr> <wbr><br /> <wbr> <wbr> <wbr> die('Not found the <br />forumhash.'); <wbr> <wbr> <wbr><br />} <wbr> <wbr> <wbr><br /> <wbr> <wbr><br />//POST数据，获取COOKIE <wbr> <wbr> <wbr><br />$cookie_file <br />= dirname(__FILE__) . '/cookie.txt'; <wbr> <wbr> <wbr><br />//$cookie_file = <br />tempnam('/tmp'); <wbr> <wbr> <wbr><br />$ch = <br />curl_init($login_url); <wbr> <wbr> <wbr><br />curl_setopt($ch, CURLOPT_HEADER, <br />0); <wbr> <wbr> <wbr><br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, <br />1); <wbr> <wbr> <wbr><br />curl_setopt($ch, CURLOPT_POST, <br />1); <wbr> <wbr> <wbr><br />curl_setopt($ch, CURLOPT_POSTFIELDS, <br />$post_fields); <wbr> <wbr> <wbr><br />curl_setopt($ch, CURLOPT_COOKIEJAR, <br />$cookie_file); <wbr> <wbr> <wbr><br />curl_exec($ch); <wbr> <wbr> <wbr><br />curl_close($ch); <wbr> <wbr> <wbr><br /> <wbr> <wbr><br />//带着上面得到的COOKIE获取需要登录后才能查看的页面内容 <wbr> <wbr> <wbr><br />$ch <br />= curl_init($get_url); <wbr> <wbr> <wbr><br />curl_setopt($ch, CURLOPT_HEADER, <br />0); <wbr> <wbr> <wbr><br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, <br />0); <wbr> <wbr> <wbr><br />curl_setopt($ch, CURLOPT_COOKIEFILE, <br />$cookie_file); <wbr> <wbr> <wbr><br />$contents = <br />curl_exec($ch); <wbr> <wbr> <wbr><br />curl_close($ch); <wbr> <wbr> <wbr><br /> <wbr> <wbr><br />var_dump($contents); <wbr> <wbr> <wbr></p><img src ="http://www.blogjava.net/lyjjq/aggbug/391506.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2012-11-17 20:42 <a href="http://www.blogjava.net/lyjjq/articles/391506.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP中的字符串函数（String </title><link>http://www.blogjava.net/lyjjq/articles/390908.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Tue, 06 Nov 2012 16:29:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/390908.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/390908.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/390908.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/390908.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/390908.html</trackback:ping><description><![CDATA[<div>手中的PHP手册不知道具体是哪个版本的，只知道是PHP5.1的，有94个字符串处理函数，真的是有够多，下面开始按照从简单到复杂的顺序介绍这些函数的使用功能和使用方法：<br />先给出一个总表：<br />addcslashes <br />&#8212; 为字符串里面的部分字符添加反斜线转义字符<br />addslashes &#8212; 用指定的方式对字符串里面的字符进行转义<br />bin2hex &#8212; <br />将二进制数据转换成十六进制表示<br />chop &#8212; rtrim() 的别名函数<br />chr &#8212; 返回一个字符的ASCII码<br />chunk_split &#8212; <br />按一定的字符长度将字符串分割成小块<br />convert_cyr_string &#8212; 将斯拉夫语字符转换为别的字符<br />convert_uudecode &#8212; <br />解密一个字符串<br />convert_uuencode &#8212; 加密一个字符串<br />count_chars &#8212; 返回一个字符串里面的字符使用信息<br />crc32 <br />&#8212; 计算一个字符串的crc32多项式<br />crypt &#8212; 单向散列加密函数<br />echo &#8212; 用以显示一些内容<br />explode &#8212; <br />将一个字符串用分割符转变为一数组形式<br />fprintf &#8212; <br />按照要求对数据进行返回，并直接写入文档流<br />get_html_translation_table &#8212; 返回可以转换的HTML实体<br />hebrev &#8212; <br />将Hebrew编码的字符串转换为可视的文本<br />hebrevc &#8212; 将Hebrew编码的字符串转换为可视的文本<br />html_entity_decode &#8212; <br />htmlentities ()函数的反函数，将HTML实体转换为字符<br />htmlentities &#8212; <br />将字符串中一些字符转换为HTML实体<br />htmlspecialchars_decode &#8212; <br />htmlspecialchars()函数的反函数，将HTML实体转换为字符<br />htmlspecialchars &#8212; <br />将字符串中一些字符转换为HTML实体<br />implode &#8212; 将数组用特定的分割符转变为字符串<br />join &#8212; <br />将数组转变为字符串，implode()函数的别名<br />levenshtein &#8212; 计算两个词的差别大小<br />localeconv &#8212; <br />获取数字相关的格式定义<br />ltrim &#8212; 去除字符串左侧的空白或者指定的字符<br />md5_file &#8212; 将一个文件进行MD5算法加密<br />md5 &#8212; <br />将一个字符串进行MD5算法加密<br />metaphone &#8212; 判断一个字符串的发音规则<br />money_format &#8212; <br />按照参数对数字进行格式化的输出<br />nl_langinfo &#8212; 查询语言和本地信息<br />nl2br &#8212; 将字符串中的换行符&#8220;\n&#8221;替换成&#8220;&lt;br <br />/&gt;&#8221;<br />number_format &#8212; 按照参数对数字进行格式化的输出<br />ord &#8212; 将一个ASCII码转换为一个字符<br />parse_str <br />&#8212; 把一定格式的字符串转变为变量和值<br />print &#8212; 用以输出一个单独的值<br />printf &#8212; <br />按照要求对数据进行显示<br />quoted_printable_decode &#8212; 将一个字符串加密为一个8位的二进制字符串<br />quotemeta &#8212; <br />对若干个特定字符进行转义<br />rtrim &#8212; 去除字符串右侧的空白或者指定的字符<br />setlocale &#8212; <br />设置关于数字，日期等等的本地格式<br />sha1_file &#8212; 将一个文件进行SHA1算法加密<br />sha1 &#8212; <br />将一个字符串进行SHA1算法加密<br />similar_text &#8212; 比较两个字符串，返回系统认为的相似字符个数<br />soundex &#8212; <br />判断一个字符串的发音规则<br />sprintf &#8212; 按照要求对数据进行返回，但是不输出<br />sscanf &#8212; <br />可以对字符串进行格式化<br />str_ireplace &#8212; 像str_replace()函数一样匹配和替换字符串，但是不区分大小写<br />str_pad &#8212; <br />对字符串进行两侧的补白<br />str_repeat &#8212; 对字符串进行重复组合<br />str_replace &#8212; 匹配和替换字符串<br />str_rot13 &#8212; <br />将字符串进行ROT13加密处理<br />str_shuffle &#8212; 对一个字符串里面的字符进行随机排序<br />str_split &#8212; <br />将一个字符串按照字符间距分割为一个数组<br />str_word_count &#8212; 获取字符串里面的英文单词信息<br />strcasecmp &#8212; <br />对字符串进行大小比较，不区分大小写<br />strchr &#8212; 通过比较返回一个字符串的部分strstr()函数的别名<br />strcmp &#8212; <br />对字符串进行大小比较<br />strcoll &#8211; 根据本地设置对字符串进行大小比较<br />strcspn &#8212; <br />返回字符连续非匹配长度的值<br />strip_tags &#8212; 去除一个字符串里面的HTML和PHP代码<br />stripcslashes &#8212; <br />反转义addcslashes()函数转义处理过的字符串<br />stripos &#8212; 查找并返回首个匹配项的位置，匹配不区分大小写<br />stripslashes <br />&#8212; 反转义addslashes()函数转义处理过的字符串<br />stristr &#8212; 通过比较返回一个字符串的部分，比较时不区分大小写<br />strlen &#8212; <br />获取一个字符串的编码长度<br />strnatcasecmp &#8212; 使用自然排序法对字符串进行大小比较，不区分大小写<br />strnatcmp &#8212; <br />使用自然排序法对字符串进行大小比较<br />strncasecmp &#8212; 对字符串的前N个字符进行大小比较，不区分大小写<br />strncmp &#8212; <br />对字符串的前N个字符进行大小比较<br />strpbrk &#8212; 通过比较返回一个字符串的部分<br />strpos &#8212; <br />查找并返回首个匹配项的位置<br />strrchr &#8212; 通过从后往前比较返回一个字符串的部分<br />strrev &#8212; <br />将字符串里面的所有字母反向排列<br />strripos &#8212; 从后往前查找并返回首个匹配项的位置，匹配不区分大小写<br />strrpos &#8211; <br />从后往前查找并返回首个匹配项的位置<br />strspn &#8212; 匹配并返回字符连续出现长度的值<br />strstr &#8212; <br />通过比较返回一个字符串的部分<br />strtok &#8212; 用指定的若干个字符来分割字符串<br />strtolower &#8212; <br />将字符串转变为小写<br />strtoupper &#8211;将字符串转变为大写<br />strtr &#8212; 对字符串比较替换<br />substr_compare &#8212; <br />对字符串进行截取后的比较<br />substr_count &#8212; 计算字符串中某字符段的出现次数<br />substr_replace &#8212; <br />对字符串中的部分字符进行替换<br />substr &#8212; 对字符串进行截取<br />trim &#8212; 去除字符串两边的空白或者指定的字符<br />ucfirst &#8212; <br />将所给字符串的第一个字母转换为大写<br />ucwords &#8212; 将所给字符串的每一个英文单词的第一个字母变成大写<br />vfprintf &#8212; <br />按照要求对数据进行返回，并直接写入文档流<br />vprintf &#8212; 按照要求对数据进行显示<br />vsprintf &#8212; <br />按照要求对数据进行返回，但是不输出<br />wordwrap &#8212; <br />按照一定的字符长度分割字符串<br />strtolower()函数把所有字符变成小写，strtoupper()函数把所有字符变成大写，ucfirst()函数将所给字符串的第一个字母转换为大写，ucwords()函数将所给字符串的每一个英文单词的第一个字母变成大写。<br />ucfirst()只处理字符串的首个字符，ucwords()只处理每个单词的首字母（以空格来界定是否是单词，&#8220;today!Hi&#8221;、&#8220;today.Hi&#8221; <br />会被认为是一个单词），对于其余字母的大小写状态并不改变。<br />[php]&lt;?php<br />echo strtolower("ABCD");//显示 <br />abcd<br />echo strtoupper("abcd");//显示 ABCD<br />echo ucfirst("what a beautiful day <br />today!");//显示 What a beautiful day today!<br />echo ucwords("what a beautiful day <br />today!");//显示 What A Beautiful Day <br />Today!<br />?&gt;[/php]<br />trim()函数去除字符串两边的空白或者指定的字符，ltrim()函数去除字符串左侧的空白或者指定的字符，rtrim()函数去除字符串右侧的空白或者指定的字符，chop()函数和rtrim()函数功能相同，这四个函数都不支持UFT-8中文字符。<br />[php]&lt;?php<br />echo <br />trim("what a beautiful day today!","! adlotwy");//显示 hat a beautifu<br />echo <br />ltrim("what a beautiful day today!","! adlotwy");//显示 hat a beautiful day <br />today!<br />echo rtrim("what a beautiful day today!","! adlotwy");//显示 what a <br />beautifu<br />echo chop("what a beautiful day today!","! adlotwy");//显示 what a <br />beautifu<br />?&gt;[/php]<br />echo()函数用以显示一些内容，可以使用&lt;&lt;《What is the difference <br />between echo and print》 查看两者的差别。echo() 和 <br />print()后面的小括号，可加可不加。<br />[php]&lt;?php<br />$temp = "都";<br />echo <br />$temp;//显示&#8220;都&#8221;<br />echo <br />&lt;&lt;&lt;END<br />大<br />家<br />$temp<br />好<br />吗<br />？<br />END;//显示&#8220;大家都好吗？&#8221;<br />echo <br />"大家",$temp,"好！";//显示&#8220;大家都好&#8221;<br /><br />$temp = "都";<br />print $temp; //显示&#8220;都&#8221;<br />print <br />&lt;&lt;&lt;END<br />大<br />家<br />$temp<br />好<br />吗<br />？<br />END;//显示&#8220;大家都好吗？&#8221;<br />?&gt;[/php]<br />printf()函数可以按照要求对数据进行显示，该函数的功能异常强大，即可以让值在不同的字符格式和进制之间转换，还可以实现字符补白（pad）和截取等功能。sprintf()函数，fprintf()函数的功能和printf()函数完全一样，只不过sprintf()函数是返回结果而不是直接输出，fprintf()必须用在将输出写入文档流的时候。下面仅以printf()函数举例：<br />在printf()函数的第一个参数中：<br />% <br />- 转义字符（在%开始，字母结束的格式定义内部，使用&#8220;&#8217;&#8221;进行转义）<br />b &#8211; 二进制格式输出<br />c - 将ASCII值转变为对应的值输出<br />d &#8211; <br />有符号的十进制数输出（整数）<br />e &#8211; 科学计数法输出<br />u &#8211; 无符号的十进制数输出（正数）<br />f &#8211; 浮点格式输出（locale <br />aware）<br />F &#8211; 浮点格式输出（non-locale aware）<br />o &#8211; 八进制格式输出<br />s &#8211; 字符串格时输出<br />x &#8211; <br />十六进制格式输出（字母小写）<br />X - 十六进制格式输出（字母大写）<br />[php]&lt;?php<br />$n =&nbsp; 43951789;<br />$u = <br />-43951789;<br />$c = 65; // 'A'的ASCII值为65<br />printf("%b", $n); <br />//显示10100111101010011010101101<br />printf("%c", $c); //显示A<br />printf("%d", $n); <br />//显示43951789<br />printf("%e", $n); //显示4.39518e+7<br />printf("%u", $n); <br />//显示43951789<br />printf("%u", $u); //显示4251015507<br />printf("%f", $n); <br />//显示43951789.000000<br />printf("%F", $n); //显示43951789.000000<br />printf("%o", <br />$n); //显示247523255<br />printf("%s", $n); //显示43951789<br />printf("%x", $n); <br />//显示29ea6ad<br />printf("%X", $n); //显示29EA6AD<br />printf("%+d", $n); <br />//显示+43951789<br />printf("%+d", $u); <br />//显示-43951789<br />?&gt;[/php]<br />printf的第一个参数还内置了类似正则的功能：<br />1、第一位是可选的一个&#8220;+&#8221;，这个符号只对数字格式的输出有效，因为如果是负数的话，前面会有一个&#8220;-&#8221;，有时候会需要在正数前面加一个&#8220;+&#8221;，但是PHP默认是隐去&#8220;+&#8221;号显示的，所以需要在前面加一个&#8220;+&#8221;输出&#8220;+&#8221;号<br />2、第二位是可选的填充字符，用这个字符来起到填充空白的左右，功能类似str_pad()函数，保留字符可以用&#8220;&#8217;&#8221;转义<br />3、第三位表示填充的方向，是可选的，&#8220;+&#8221;是默认值，表示在左侧填充，&#8220;-&#8221;表示在右侧填充<br />4、第四位表示填充完成后的长度，也是可选的，没有这个参数就表示不进行填充<br />5、第五位可选参数，如果输出是浮点数，可以控制小数点后面的个数，如果是输出字符串，则可以用来截取字符串的长度，使用时为了和前面的参数区分，需要用&#8220;.&#8221;隔开<br />[php]&lt;?php<br />$t <br />= 'many monkeys';<br />$n = 1213;<br />printf("%+d",$n); // 1、显示 <br />+1213<br />printf("%010d",$n); // 2、显示000001213<br />printf("%+'#10d",$n); // 2、显示 <br />#####+1213<br />printf("%+'#-10d",$n); // 3、显示 +1213#####<br />printf("%.2f",$n); // <br />5、显示 1213.00<br />printf("%.7s",$t); // 5、显示 many <br />mo<br />?&gt;[/php]<br />了解了上面这些之后，让我们看printf()函数的使用方法，其实就是将接受的从第二个参数以后的所有参数一个一个的在第一个参数中需要转换的地方输出，如果参数次序被打乱，就需要使用&#8220;2\$&#8221;这样的字符来表明变量的位置。<br />[php]&lt;?php<br />$num <br />= "tree";<br />$location = 10;<br />$format1 = "The %s contains %d <br />monkeys";<br />printf($format1, $num, $location);<br />//显示 The tree contains 10 <br />monkeys<br />$format2 = "The %s contains %d monkeys";<br />printf($format2, <br />$location, $num);<br />//显示 The tree contains 10 <br />monkeys<br />?&gt;[/php]<br />vprintf()函数、vsprintf()函数、vfprintf()函数三个函数的功能和上面的printf()函数、sprintf()函数、fprintf()的功能一样，vprintf()函数直接输出，vsprintf()函数返回但是不输出，vfprintf()函数直接将结果输出到文档流，区别就是这三个函数接受的参数都是数组形式的，而不是一个一个的变量。<br />这里只举vprintf()函数的例子：<br />[php]&lt;?php<br />$num <br />= "tree";<br />$location = 10;<br />$argu1 = array("tree",10);<br />$argu2 = <br />array(10,"tree");<br />$format1 = "The %s contains %d <br />monkeys";<br />printf($format1, $num, $location);<br />// 显示 The tree contains 10 <br />monkeys<br />$format1 = "The %s contains %d monkeys";<br />vprintf($format1, <br />$argu1);<br />// 显示 The tree contains 10 monkeys<br />$format2 = "The %2\$s contains <br />%1\$d monkeys";<br />vprintf($format2, $argu2);<br />// 显示 The tree contains 10 <br />monkeys<br />?&gt;[/php]<br />number_format()函数可以按照参数对数字进行格式化的输出，number_format()函数最多有4个参数，第一个参数是输出的数字，第二个参数表示保留几位小数，第三个参数和第四个参数必须同时使用（就是说不能只用第三个参数，而不使用第四个参数），分别表示小数点的样式和千分符的样式，默认分别为&#8220;.&#8221;和&#8220;,&#8221;。<br />[php]&lt;?php<br />$num <br />= 1234.56;<br />$new_num = number_format($num, 3, ".", "-");<br />echo $new_num; // <br />显示 <br />1-234.560<br />?&gt;[/php]<br />money_format()函数需要C里面的strfmon()函数支持，所以需要系统能够提供C函数库，很显然，windows系统无法支持此功能，所以在windows下面的PHP环境不支持money_format()函数，此函数的介绍以后再补充：（<br />sscanf()函数可以对字符串进行格式化，第一个参数表示需要处理的字符，第二个参数表示变量匹配的规则（匹配规则请参照上面的printf()函数），后面的参数可选，分别对应需要赋值的变量，如果仅仅只有2个参数，那么所有的变量值将以一个数组的形式返回。在下面的例子中，&#8220;%s&#8221;的匹配是贪婪的，所以在使用时要注意。<br />[php]&lt;?php<br />$mandate <br />= "January 01 2000";<br />list($month, $day, $year) = sscanf($mandate, "%s %d <br />%d");<br />echo "$year-" .$month. "-$day";// 显示 <br />2000-January-1<br />?&gt;[/php]<br />str_replace()函数可以匹配和替换字符串，第一个参数表示需要匹配的项，第二个参数表示替换的项，第三个参数表示处理的字符串。第四个参数可选，将一个变量赋值为匹配的次数，前两个参数也可以是数组形式的。str_ireplace()函数的功能和str_replace()函数类似，只不过在匹配的时候str_ireplace()函数会忽略大小写。<br />[php]&lt;?php<br />$str1 <br />= str_replace("world", "body", "hello world world");<br />echo $str1;// 显示 hello <br />body body<br />$str1 = str_ireplace("WORLD", "body", "hello world world");<br />echo <br />$str1;// 显示 hello body body<br /><br />$phrase&nbsp; = "You should eat fruits, <br />vegetables, and fiber every day.";<br />$healthy = array("fruits", "vegetables", <br />"fiber");<br />$yummy&nbsp;&nbsp; = array("pizza", "beer", "ice cream");<br />$newphrase = <br />str_replace($healthy, $yummy, $phrase, $count);<br />echo $newphrase;// 显示 You <br />should eat pizza, beer, and ice cream every day.<br />echo $count; // 显示 <br />3<br />?&gt;[/php]<br />strtr()函数的作用是对字符串替换，strtr()函数有两种使用方法，第一种使用三个参数，替换时会将第二个参数的字符串替换为第三个参数的字符串（如果两个字符串参数的长度不一致，则教长的那个字符串将会被截断），第二种方法使用两个参数，第二个参数是一个准备进行替换处理的数组。<br />[php]&lt;?php<br />$trans <br />= strtr("hello world", "world", "body");<br />echo $trans;//显示 heyyo bodyd <br />（w=&gt;b，o=&gt;o，r=&gt;d，l=&gt;y）<br />$arr = array("hello" =&gt; "hi", "hi" =&gt; <br />"hello");<br />$trans = strtr("hi all, I said hello", $arr);<br />echo $trans;//显示 <br />hello all, I said <br />hi<br />?&gt;[/php]<br />strstr()函数通过比较返回一个字符串的部分。函数有两个参数，第一个参数表示处理的字符串，第二个参数表示匹配项，返回结果为从匹配位置开始到最后的一个字符串，如果没有匹配，则返回false。strchr()函数是strstr()函数的别名，功能和使用方法完全一样。strrchr()函数的功能和strstr()函数类似，区别是strrchr()函数是从后向前匹配的，stristr()函数的功能和strstr()函数一样，但是匹配是不区分字母的大小写。strpbrk()的功能和strstr()函数类似，是在一个字母串里面找出第一个匹配项，返回以后的结果。<br />[php]&lt;?php<br />$email <br />= [email=]'user@example.com'[/email];<br />$domain = strstr($email, <br />[email=]'@'[/email]);<br />echo $domain; // 显示 @example.com<br />$exam = <br />strrchr($email, 'e');<br />echo $exam; // 显示 e.com<br />$exam = stristr($email, <br />'EX');<br />echo $exam; // 显示 example.com<br />$exam = strpbrk($email, <br />'pe');<br />echo $exam; // 显示 <br /><br />?&gt;[/php]<br />strpos()函数查找并返回首个匹配项的位置，第一个参数表示处理的字符串，第二个参数表示匹配项，第三个参数可选，表示开始执行查找的位置。stripos()函数的功能和strpos()函数类似，区别是匹配的时候不会区分大小写。strrpos()函数和strpos()函数功能类似，区别是从后往前匹配，strripos()函数的功能和strrpos()函数类似，区别是不区分大小写。strrpos()函数在PHP4中只支持单个字母的查找，如果参数是字符串，则截取第一个字母，PHP4不支持strripos()函数。<br />[php]&lt;?php<br />$newstring <br />= 'abcdef abcdefab';<br />$pos = strpos($newstring, 'a', 1);<br />echo $pos; // 显示 <br />7<br />$pos = strrpos($newstring, 'ab', 6);<br />echo $pos; // 显示 <br />13<br />?&gt;[/php]<br />count_chars()函数的作用是返回一个字符串里面的字符使用信息。第二个参数五个参数：<br />0 - <br />以所有的每个字节值作为键名，出现次数作为值的数组。<br />1 - 与 0 相同，但只列出出现次数大于零的字节值。<br />2 - 与 0 <br />相同，但只列出出现次数等于零的字节值。<br />3 - 返回由所有使用了的字节值组成的字符串。<br />4 - <br />返回由所有未使用的字节值组成的字符串。<br />[php]&lt;?php<br />$da<wbr>ta = "this is a test <br />world";<br />print_r(count_chars($da<wbr>ta, 1)); // 显示用到字符信息 <br /><br />print_r(count_chars($da<wbr>ta, 3)); // 显示 <br />adehilorstw<br />?&gt;[/php]<br />strspn()函数的作用是匹配并返回第二个参数里面的单字符连续出现长度的值，strspn()函数的第三个参数和第四个参数可选，分别表示开始匹配的位置和返回的最大值。strcspn()函数的使用方法和strspn()函数类似，但功能却相反，返回的是第二个参数中不匹配的字符串长度。<br />[php]&lt;?php<br />$var <br />= strspn("42123 is the answer", "1234567890");<br />echo $var; //显示 5<br />echo <br />strspn("faoaaol", "oa", 1, 3); // 显示 3<br />echo strcspn("csdcsdfaoaaol", "oa", 1, <br />9); // 显示 <br />6<br />?&gt;[/php]<br />substr()函数可以对字符串进行截取，substr()函数可以有三个参数，第二个参数如果是空，那么默认就为0，如果我负数，就表示从后往前计数，第三个参数如果是正数，表示字符串截取的长度，如果省略，则会一直截取到最后，如果是负数，则表示从后往前截取到的位置。<br />[php]&lt;?php<br />echo <br />substr('abcdef',3, 2);&nbsp; // 显示 de<br />echo substr('abcdef',"", 2);&nbsp; // 显示 <br />ab<br />echo substr("abcdef", -2);&nbsp;&nbsp;&nbsp; // 显示 ef<br />echo substr("abcdef", -3, 1); // <br />显示 d<br />echo substr("abcdef", -3, -1); // 显示 <br />de<br />?&gt;[/php]<br />substr_count()函数的作用是计算字符串中某字符段的出现次数，第三个参数表示在字符串中开始比较的位置，省略则默认从头开始，第四个参数表示依次比较的字符数，省略则表示一直比较到末尾。和substr()函数有所不同的是，这两个参数都不支持负数。<br />[php]&lt;?php<br />$text <br />= 'This is a test';<br />echo substr_count($text, 'is'); // 显示 2<br />echo <br />substr_count($text, 'is', 3); // 显示 1<br />echo substr_count($text, 'is', 3, 3); <br />// 显示 <br />0<br />?&gt;[/php]<br />substr_replace()函数的作用是对字符串中的部分字符进行替换，substr_replace()函数的第三个参数必选，表示需要处理字符的起始位置，负数表示从后往前计数，第四个参数可选，省略表示一直替换到最后，正数表示替换的长度，负数表示从后往前替换到的位置。<br />[php]&lt;?php<br />$var <br />= 'ABCDEFGH:/MNRPQR/';<br />echo substr_replace($var, 'bob', 0); // 显示 bob<br />echo <br />substr_replace($var, 'bob', 0, 0); // 显示 bobABCDEFGH:/MNRPQR/<br />echo <br />substr_replace($var, 'bob', 10, -1); // 显示 ABCDEFGH:/bob/<br />echo <br />substr_replace($var, 'bob', -7, -1); // 显示 ABCDEFGH:/bob/<br />echo <br />substr_replace($var, '', 10, -1); // 显示 <br />ABCDEFGH://<br />?&gt;[/php]<br />implode()函数的作用是将数组转变为字符串，explode()函数的作用是将一个字符串转变为一数组形式。implode()函数前两个参数的位置是任意的，而explode()函数则不行。explode()函数第三个参数可选，省略则表示全部返回，正数表示返回的数组中单元的个数，最后一个单元包含了未处理完的字符串，负数表示返回值中将除去最后的若干个单元。join()函数的作用和implode()函数相同，是implode()函数的别名。<br />[php]&lt;?php<br />$array <br />= array('lastname', 'email', 'phone');<br />echo implode($array,","); // 显示 <br />lastname,email,phone<br />$str = 'on<wbr>e|two|three';<br />print_r(explode('|', <br />$str));// 显示 Array ( [0] =&gt; on<wbr>e [1] =&gt; two [2] =&gt; three <br />)<br />print_r(explode('|', $str, 2));// 显示 Array ( [0] =&gt; on<wbr>e [1] =&gt; <br />two|three )<br />print_r(explode('|', $str, -1));// 显示 Array ( [0] =&gt; on<wbr>e <br />[1] =&gt; two <br />)<br />?&gt;[/php]<br />strtok()函数的作用是用指定的若干个字符来分割字符串，此函数的功能较强大，但是使用方法比较特殊。在连续使用的时候，第一次需要说明字符串和分割符，但是第二次的时候，只要放入分割符就可以，分割符可以是多个内容，但是不能使用字符串，具体请研究下面的例子：<br />[php]&lt;?php<br />$string <br />= "This is\tan example\nstring";<br />$tok = strtok($string, " <br />\n\t");<br /><br />while ($tok !== false) {<br />&nbsp;&nbsp;&nbsp; echo "$tok&lt;br /&gt;";<br />&nbsp;&nbsp;&nbsp; <br />$tok = strtok(" <br />\n\t");<br />}<br />?&gt;[/php]<br />str_split()函数的作用是将一个字符串按照字符间距分割为一个数组，str_split()函数有两个参数，第二个参数可选，默认值为&#8220;1&#8221;。<br />[php]&lt;?php<br />$str1 <br />= "asd";<br />$str2 = "Hello Friend";<br />print_r(str_split($str1)); // 显示 Array ( <br />[0] =&gt; a [1] =&gt; s [2] =&gt; d )<br />print_r($arr2 = str_split($str2, 4)); <br />// 显示 Array ( [0] =&gt; Hell [1] =&gt; o Fr [2] =&gt; iend <br />)<br />?&gt;[/php]<br />chunk_split()函数的作用是按一定的字符长度将字符串分割成小块，第二个参数可选，表示字符间距，默认为76，第三个参数可选，表示用什么字符进行分割，默认为&#8220;\r\n&#8221;。<br />[php]&lt;?php<br />$str <br />= "asdasdasd";<br />echo chunk_split($str,3,","); // 显示 <br />asd,asd,asd,<br />?&gt;[/php]<br />wordwrap()函数的作用是按照一定的字符长度分割字符串，第二个参数可选，表示按多少字符进行分割，默认为75，第三个参数可选，表示用哪个字符分割，默认为&#8220;\n&#8221;，第四个参数可选，true表示强制打破一个单词，false表示不大破单词，默认为false。<br />[php]&lt;?php<br />$text <br />= "A very long woooooooooood asdasd";<br />echo wordwrap($text, 12, "&lt;br <br />/&gt;\n", true); // woooooooooood被打破<br />echo wordwrap($text, 12, "&lt;br <br />/&gt;\n", false); // <br />woooooooooood未被打破<br />?&gt;[/php]<br />strlen()函数的作用是获取一个字符串的编码长度。<br />[php]&lt;?php<br />$text1 <br />= "ABC";<br />$text2 = "中文";<br />echo strlen($text1); // 显示 3<br />echo <br />strlen($text2); // 显示 <br />6<br />?&gt;[/php]<br />str_word_count()函数的作用是获取字符串里面的英文单词信息，第二个参数可选，0表示只返回单词的个数，1表示将找到的单词作为一个数组返回，2表示找到的单词和单词所在的字符位置信息作为一个联合数组（associative）返回，省略的默认值是0；第三个参数也是可选的，表示需要忽略的断词符号，默认的断词符号有空格，数字等等，有时候需要忽略一些。<br />[php]&lt;?php<br />$str <br />= "Hello fri3nd, you're<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; looking&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; good today!";<br />echo <br />str_word_count($str); // 显示 7<br />print_r(str_word_count($str, 1));<br />// 显示 <br />Array ( [0] =&gt; Hello [1] =&gt; fri [2] =&gt; nd [3] =&gt; good [4] =&gt; <br />today )<br />print_r(str_word_count($str, 2)); <br />// 显示 Array ( [0] =&gt; Hello <br />[6] =&gt; fri [10] =&gt; nd [14] =&gt; good [19] =&gt; today <br />)<br />print_r(str_word_count($str, 1, '&#224;&#225;~ac3')); <br />// 显示 Array ( [0] =&gt; <br />Hello [1] =&gt; fri3nd [2] =&gt; good [3] =&gt; today <br />)<br />?&gt;[/php]<br />nl_langinfo()函数的作用是获取某些字符信息，但是没有在windows平台下实现，所以，我以后在讨论。<br />localeconv()函数的作用是获取数字相关的格式定义。setlocale()函数可以设置关于数字，日期等等的本地格式，相关内容较复杂，这里省略不谈。这两个函数的作用是为了解决在不同的国家地区之间，对数字，货币，日期等字符形式不同的表现内容而进行简易设置的作用。<br />strrev()函数的作用是将字符串里面的所有字母反向排列。str_shuffle()函数的作用是对一个字符串里面的字符进行随机排序。<br />[php]&lt;?php<br />echo <br />strrev("ABC"); // 显示 CBA<br />$str = 'abcdef';<br />echo <br />str_shuffle($str);<br />?&gt;[/php]<br />str_pad()函数的作用是对字符串进行两侧的补白，第二个参数表示补白以后的长度，第三个参数可选，表示进行补白的字符串，默认为空格，第四个参数可选，表示补白的方式，有三个常量可以选择：STR_PAD_RIGHT，STR_PAD_LEFT和STR_PAD_BOTH，分别表示右补白，左补白和两侧补白，默认值为STR_PAD_RIGHT。<br />[php]&lt;?php<br />$input <br />= "Alien";<br />echo str_pad($input, 10);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 显示 "Alien&nbsp; <br />&nbsp;&nbsp; "<br />echo str_pad($input, 10, "-=", STR_PAD_LEFT);&nbsp; // 显示 <br />"-=-=-Alien"<br />echo str_pad($input, 10, "_", STR_PAD_BOTH);&nbsp;&nbsp; // 显示 <br />"__Alien___"<br />echo str_pad($input, 6 , "___");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 显示 <br />"Alien_"<br />?&gt;[/php]<br />str_repeat()函数的作用是对字符串进行重复组合，第二个参数表示重复的次数，值为0的时候将返回一个空字符串。<br />[php]&lt;?php<br />echo <br />str_repeat("ab", 3); // 显示 <br />ababab<br />?&gt;[/php]<br />chr()函数的作用是返回一个字符的ASCII码，ord()函数的作用是将一个ASCII码转换为一个字符。<br />[php]&lt;?php<br />$str <br />= "a";<br />echo ord($str); // 显示 97<br />$asc2 = 97;<br />echo chr($asc2); //显示 <br />a<br />?&gt;[/php]<br />strcmp()函数的作用是对字符串进行大小比较，第一个参数大于第二个参数时返回一个大于0的数，小于则返回一个小于0的数，等于则返回0，此函数的比较结果返回值是非常令人困惑的，因而此函数的主要用处是比较两个字符串是否相等。strncmp()函数的作用和strcmp()函数类似，区别是strncmp()函数有第三个必选参数，用来限制进行比较的前N个字符。strcasecmp()的作用和strcmp()函数类似，区别是strcasecmp()函数忽略大小写。strncasecmp()函数的作用和strncmp()函数类似，区别是strncasecmp()函数忽略大小写。strnatcmp()函数的作用和strcmp()函数类似，区别是strnatcmp()函数使用自然排序法对字符串之间进行比较。strnatcasecmp()函数的作用和strnatcmp()函数类似，区别是strnatcasecmp()函数比较时不区分大小写。strcoll()函数的作用和strcmp()函数类似，区别是strcoll()函数会根据本地环境的设置而改变比较的方式，而产生不同的结果，这里暂时跳过不讨论。<br />[php]&lt;?php<br />echo <br />strcmp("red", "red"); // 显示 0<br />echo strncmp("red apple", "red", 3); // 显示 <br />0<br />echo strcasecmp("Red", "red"); // 显示 0<br />echo strncasecmp("Red apple", <br />"red", 3); // 显示 <br />0<br />?&gt;[/php]<br />上面这些函数的另一个作用是被作为回调函数的形式使用（其实也是最主要的用途所在）：<br />[php]&lt;?php<br />$arr1 <br />= $arr2 = array("img12.png", "img10.png", "img2.png", <br />"img1.png");<br />usort($arr1, "strcmp");<br />print_r($arr1); // <br />显示标准排序以后的结果<br />usort($arr2, "strnatcmp");<br />print_r($arr2); // <br />显示自然排序以后的结果<br />?&gt;[/php]<br />substr_compare()函数可以对字符串进行截取后的比较，第三个参数表示比较开始的起始位置，第四个参数可选，表示进行比较的长度，省略则表示一直比较到末尾，第五个参数可选，设置为true可以忽略大小写，false表示不忽略大小写，默认值为false。<br />[php]&lt;?php<br />echo <br />substr_compare("abcde", "bc", 1, 2); // 显示 0<br />echo substr_compare("abcde", <br />"bcg", 1, 2); //显示 0<br />echo substr_compare("abcde", "BC", 1, 2, true); //显示 <br />0<br />echo substr_compare("abcde", "bc", 1, 3); //显示 1<br />echo <br />substr_compare("abcde", "cd", 1, 2); //显示 -1<br />echo substr_compare("abcde", <br />"abc", 5, 1); //显示 <br />报错<br />?&gt;[/php]<br />similar_text()函数的作用是比较两个字符串，返回系统认为的相似字符个数，第三个参数可选，可以对一个变量附值为相似度百分比。levenshtein()函数的作用是对字符串进行比较，并且返回两个字符串的相似度，有三个可选参数，但是不知道如何使用。<br />&lt;?<br />echo <br />similar_text("abcdas", "abdcas", $p); // 显示 5<br />echo "$p%"; // 显示 <br />83.3333333333%<br />echo levenshtein("ab", "abcd"); // 显示 2<br />echo <br />levenshtein("abc", "abcd"); // 显示 1<br />echo levenshtein("abcd", "abcd"); // 显示 <br />0<br />?&gt;[/php]<br />soundex()函数的作用是判断一个字符串的发音规则，用4位的字符串表示。metaphone()函数的作用是判断一个字符串的发音规则，和soundex()函数类似，但是显示的是一个不定长的字符串。<br />[php]&lt;?php<br />echo <br />soundex("Ellery");&nbsp;&nbsp;&nbsp; // 显示 E460<br />echo soundex("Ghosh");&nbsp;&nbsp;&nbsp;&nbsp; // 显示 <br />G200<br />echo soundex("Heilbronn"); // 显示 H416<br />echo metaphone("Ellery");&nbsp;&nbsp;&nbsp; // <br />显示 ELR<br />echo metaphone("Ghosh");&nbsp;&nbsp;&nbsp;&nbsp; // 显示 FX<br />echo metaphone("Heilbronn"); <br />// 显示 <br />HLBRN<br />?&gt;[/php]<br />addslashes()函数的作用是为字符串里面的部分字符添加反斜线转义字符，addslashes()函数只为4个字符添加转义，单引号&#8220;&#8217; <br />&#8221;，双引号&#8220;&#8221;&#8221;,反斜线&#8220;\&#8221;和NULL（&#8220;\0&#8221;）。addcslashes()函数的作用也是对字符串添加转义，但是转义的字符必须由第二个参数指定，第二个参数的使用方法难度太高，跳过不讲。stripslashes()函数的作用和addslashes()函数正好相反，可以将addslashes()函数转义的那4个字符取消转义。同样，stripcslashes()函数的作用和addcslashes()函数相反。quotemeta()函数的作用是对11个特定字符进行转义，包括：. <br />\ + * ? [ ^ ] ( $ ) 似乎是可以用在正则里面。<br />[php]&lt;?php<br />echo addslashes("'\"\ "); <br />// 显示 \'\"\\ <br />echo addcslashes("zoo['.']", 'zo'); // 显示 \z\o\o['.']<br />echo <br />addcslashes("z\"oo['.']", '\'\"'); // 显示 z\"oo[\'.\']<br />echo addcslashes('foo[ <br />]', 'A..z'); // 显示 \f\o\o\[ \]<br />echo stripslashes(addslashes("'\"\ ")); // 显示 <br />'"\<br />echo stripcslashes(addcslashes("z\"oo['.']", '\'\"')); // 显示 <br />z"oo['.']<br />echo quotemeta(". \ + * ?"); // 显示 \. \\ \+ \* <br />\?<br />?&gt;[/php]<br />htmlspecialchars()函数的作用是将字符串中一些字符转换为HTML实体，默认情况下主要包括这4个字符：&#8220;&lt;&#8221;，&#8220;&gt;&#8221;，&#8220;&amp;&#8221;和&#8220;&#8221;&#8221;，分别转换为HTML实体：&#8220;&lt;&#8221;，&#8220;&gt;&#8221;，&#8220;&amp;&#8221;呵&#8220;"&#8221;。htmlentities()函数的第二个可选参数可以选择引号的转换模式，可以选择三个常量：ENT_COMPAT表示转换双引号但是保留单引号，ENT_QUOTES表示同时转换双引号和单引号，ENT_NOQUOTES表示两个都不转换，默认值为ENT_COMPAT。第三个可选参数表示所转换字符的编码集。htmlspecialchars_decode()函数的作用和htmlspecialchars()函数刚好相反，但是两个函数的使用方法一样。<br />[php]&lt;?php<br />$str <br />= "&lt;a href='test'&gt;Test&lt;/a&gt;";<br />echo htmlspecialchars($str); // <br />显示（源代码里面） &lt;a href='test'&gt;Test&lt;/a&gt;<br />echo htmlspecialchars($str, <br />ENT_QUOTES); // 显示（源代码里面） &lt;a href='test'&gt;Test&lt;/a&gt;<br />$str = '&lt;a <br />href='test'&gt;Test&lt;/a&gt;';<br />echo htmlspecialchars_decode($str); // <br />显示（源代码里面） &lt;a <br />href='test'&gt;Test&lt;/a&gt;<br />?&gt;[/php]<br />htmlentities()函数的用法和htmlspecialchars()函数类似，但是htmlspecialchars()函数会转义更多的HTML里面的字符（请查看手册的htmlspecialchars()函数的表格1《已支持字符集》部分），所以使用时要注意加上第三个参数。html_entity_decode()函数的作用和htmlentities()函数正好相反，但是用法完全一样，使用时也要注意用到第三个参数。<br />&lt;meta <br />http-equiv="Content-Type" c /&gt;<br />[php]&lt;?php<br />$str = "&lt;a <br />href='test'&gt;中文&lt;/a&gt;";<br />echo htmlentities($str,ENT_COMPAT,"UTF-8"); <br />//显示（源代码里面） &lt;a href='test'&gt;涓枃&lt;/a&gt;<br />echo <br />html_entity_decode(htmlentities($str,ENT_COMPAT,"UTF-8"),ENT_COMPAT,"UTF-8"); // <br />显示（源代码里面） &lt;a <br />href='test'&gt;中文&lt;/a&gt;<br />?&gt;[/php]<br />get_html_translation_table()函数的作用是返回可以转换的HTML实体，算是一个比较有意思，也是有趣的工具函数。get_html_translation_table()函数有两个常量参数，第一个参数表示所选择显示哪种转换模式下的内容，HTML_ENTITIES表示大范围的htmlentities()函数所用到的转换内容，HTML_SPECIALCHARS表示小范围的htmlspecialchars()函数所用到的转换内容，第二个参数的三种模式ENT_COMPAT，ENT_QUOTES，ENT_NOQUOTES的作用，可以查看htmlspecialchars()函数里面的介绍。<br />[php]&lt;?php<br />print_r(get_html_translation_table(HTML_SPECIALCHARS,ENT_QUOTES));<br />?&gt;[/php]<br />/* <br />显示<br />Array<br />(<br />&nbsp;&nbsp;&nbsp; ["] =&gt; "<br />&nbsp;&nbsp;&nbsp; ['] =&gt; &amp;#39;<br />&nbsp;&nbsp;&nbsp; [&lt;] <br />=&gt; &lt;<br />&nbsp;&nbsp;&nbsp; [&gt;] =&gt; &gt;<br />&nbsp;&nbsp;&nbsp; [&amp;] =&gt; <br />&amp;<br />)<br />*/<br />nl2br()函数的作用是将字符串中的换行符&#8220;\n&#8221;替换成&#8220;&lt;br <br />/&gt;&#8221;。<br />[php]&lt;?php<br />echo nl2br("foo isn't\n bar"); // 显示（源代码里面） foo <br />isn't&lt;br /&gt; <br />bar<br />?&gt;[/php]<br />strip_tags()函数的作用是去除一个字符串里面的HTML和PHP代码（其实好像就是去掉&#8220;&lt;&#8221;开始&#8220;&gt;&#8221;结尾的字符串，无所谓PHP）。第二个参数表示允许出现的标签对。<br />[php]&lt;?php<br />$text <br />= '&lt;p&gt;Test paragraph.&lt;/p&gt;&lt;em&gt;Other text&lt;/em&gt;';<br />echo <br />strip_tags($text, '&lt;p&gt;'); // 显示 &lt;p&gt;Test paragraph.&lt;/p&gt;Other <br />text<br />?&gt;[/php]<br />parse_str()函数的作用是把一定格式的字符串转变为变量和值，字符串的格式和URL的格式相同。<br />[php]&lt;?php<br />parse_str('d=12&amp;c[]=as');<br />echo <br />$c[0]; // 显示 as<br />echo $d; // 显示 <br />12<br />?&gt;[/php]<br />hebrev()函数的作用是将Hebrew编码的字符串转换为可视的文本，hebrevc函数的作用是和hebrev()函数类似，区别是会将字符串里面的&#8220;\n&#8221;转变为&#8220;&lt;br&gt;\n&#8221;。hebrev()函数和hebrevc函数的第二个参数用法相同，可以设定每行的显示字符数，行末不会强制打断一个单词。<br />convert_cyr_string()函数的作用是将斯拉夫语字符转换为别的字符。<br />bin2hex()函数的作用是将二进制数据转换成十六进制的数据。<br />str_rot13函数的作用是将字符串进行ROT13加密处理，方法是将所有字符移动13个字母位置，因为英文一共是26个字母，所以该函数的加密解密可以使用同一个函数。<br />[php]&lt;?php<br />echo <br />str_rot13('str_rot13'); // 显示 fge_ebg13<br />echo <br />str_rot13(str_rot13('str_rot13')); // 显示 <br />str_rot13<br />?&gt;[/php]<br />md5()函数的作用是将一个字符串进行MD5算法加密，返回一个32位的16位字符串，第二个参数如果设置为true，将会返回一个16位的2进制字符串。md5_file()函数的作用是对文件进行MD5加密，使用方式和md5()函数相同。<br />[php]&lt;?php<br />echo <br />md5('apple'); //显示 1f3870be274f6c49b3e31a0c6728957f<br />echo bin2hex(md5('apple', <br />true)); //显示 <br />1f3870be274f6c49b3e31a0c6728957f<br />?&gt;[/php]<br />sha1()函数的作用是将一个字符串进行SHA1算法加密，返回一个40位的16位字符串，第二个参数如果设置为true，将会返回一个20位的2进制字符串。sha1_file()函数的作用是对文件进行SHA1加密，使用方式和sha1()函数相同。<br />[php]&lt;?php<br />$str <br />= 'apple';<br />echo sha1('apple'); //显示 <br />d0be2dc421be4fcd0172e5afceea3970e2f3d940<br />echo bin2hex(sha1('apple', true)); <br />//显示 <br />d0be2dc421be4fcd0172e5afceea3970e2f3d940<br />?&gt;[/php]<br />crypt()函数的作用是对一个字符串进行散列处理，返回一个加密后的字符串。第二个可选参数是一个加密参考量，crypt()函数会根据这个量来产生加密的值，第二个参数如果省略，PHP将会随机产生一个参考量；第二个参数的处理，需要根据4个PHP的预定义常量，PHP会更具预定义常量的设定，对参考量进行处理，再进行加密。<br />CRYPT_STD_DES <br />&#8211; 标准模式，获取参考量的前两位。<br />CRYPT_EXT_DES &#8211; 扩展模式，获取参考量的前九位。<br />CRYPT_MD5 &#8211; <br />MD5模式，参考量为$1$开始的一个常量CRYPT_SALT_LENGTH指定长度的字符串。<br />CRYPT_BLOWFISH &#8211; <br />河豚模式，参考量为$2$或者$2a$开始的一个16位长的字符串。<br />[php]&lt;?php<br />if (CRYPT_STD_DES == 1) <br />{<br />&nbsp;&nbsp;&nbsp; echo 'Standard DES: ' . crypt('rasmuslerdorf', 'rl');<br />} // 显示 <br />rl.3StKT.4T8M<br />if (CRYPT_EXT_DES == 1) {<br />&nbsp;&nbsp;&nbsp; echo 'Extended DES: ' . <br />crypt('rasmuslerdorf', '_J9..rasm');<br />} // 显示 _J9..rasmBYk8r9AiWNc<br />if <br />(CRYPT_MD5 == 1) {<br />&nbsp;&nbsp;&nbsp; echo 'MD5:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' . crypt('rasmuslerdorf', <br />'$1$rasmusle$');<br />} // 显示 $1$rasmusle$rISCgZzpwk3UhDidwXvin0<br />if <br />(CRYPT_BLOWFISH == 1) {<br />&nbsp;&nbsp;&nbsp; echo 'Blowfish:&nbsp;&nbsp;&nbsp;&nbsp; ' . crypt('rasmuslerdorf', <br />'$2a$07$rasmusler...........$');<br />} // 显示 <br />$2a$07$rasmuslerd............nIdrcHdxcUxWomQX9j6kvERCFjTg7Ra<br />?&gt;[/php]<br />crc32()函数的作用是计算一个字符串的crc32多项式<br />[php]&lt;?php<br />$checksum <br />= crc32("Hello World!");<br />printf("%u\n", $checksum); // 显示 <br />472456355<br />?&gt;[/php]<br />quoted_printable_decode()函数不知道什么意思。<br />convert_uuencode()函数的作用是对一个字符串进行加密，convert_uudecode()函数的作用和convert_uuencode()函数相反，可以起到解密的作用。<br />[php]&lt;?php<br />$some_string <br />= "test\ntext text\r\n";<br />echo convert_uuencode($some_string); // 显示 <br />0=&amp;5S=`IT97AT('1E&gt;'0-"@`` ` <br />echo <br />convert_uudecode(convert_uuencode($some_string)); //显示 test text <br />text<br />?&gt;[/php] </div><img src ="http://www.blogjava.net/lyjjq/aggbug/390908.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2012-11-07 00:29 <a href="http://www.blogjava.net/lyjjq/articles/390908.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ThinkPhp标签库</title><link>http://www.blogjava.net/lyjjq/articles/362377.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Mon, 31 Oct 2011 07:15:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/362377.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/362377.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/362377.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/362377.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/362377.html</trackback:ping><description><![CDATA[<div>告：在使用下列所说的任何标签库都需要</div>
<div></div>
<div>HTML第一行加入 &lt;tarlib name=&#8221;cx,html&#8221; /&gt;</div>
<div>如果想单独引入cx标签库就直接写成&lt;tarlib name=&#8221;cx&#8221; /&gt;</div>
<div>如果单独引入html标签库就直接写成&lt;tarlib name=&#8221;html&#8221; /&gt;</div>
<div></div>
<div>原则上来讲所有的标签的属性是可以不增加的(因为tp并为进行强制验证^_^),不过为了你的正常使用,请在使用的时候按照需要进行添加</div>
<div></div>
<div>首先我们来说html标签库的信息</div>
<div></div>
<div>Editor标签</div>
<div>&lt;html:editor&nbsp;id=&#8221;editory&#8221;&nbsp;name=&#8221;remarke&#8221;&nbsp;type=&#8221;FCKeditor&#8221;&nbsp;content=&#8221;&#8221; /&gt;</div>
<div></div>
<div>属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Id 属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;编辑器的id值,</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果并未填写改属性,则会默认为_editor</div>
<div></div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Name 属性 必须的</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;编辑器的 name值</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果未填写,默认为空</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Width 属性&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;编辑器的宽度</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果未填写,默认为100%</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Height 属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;编辑器的高度</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果未填写默认为320px</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Content 属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;编辑器的内容的初始化值</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果未填写,则为空</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Type 属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;编辑器的类型 默认情况下支持</div>
<div>Fckeditor &nbsp;eWebEditor &nbsp;NETEASE &nbsp;UBB</div>
<div>如果填写的编辑器类型不存在,则会默认为 TextArea标签</div>
<div>指定Fckeditor 时,文件存放路径必须为 /Public/Js/FCKeditor/</div>
<div>指定eWebEditor 时,文件存放路径必须为/Public/Js/eWebEditor/</div>
<div>指定NETEASE 时,文件存放路径必须为/Public/Js/HtmlEditor/</div>
<div>指定UBB时,文件存放路径必须为/Public/Js/</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div>imageBtn标签</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;html:imageBtn&nbsp;id=" "&nbsp;name=" "&nbsp;type=" "&nbsp;value=" "&nbsp;click=" "&nbsp;style=" "&nbsp;/&gt;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;属性：</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Id属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input的id值</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Name属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input的name值</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Type 属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input标记的类型</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果未填写 则默认为 button</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Value 属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input标记的Value值</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;click 属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input 的click执行内容,可以为js语句块,也可以为js函数</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;style 属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input标记外面生成div的样式</div>
<div></div>
<div>imgLink标签</div>
<div>&lt;html:imgLink&nbsp;id=" "&nbsp;name=" "&nbsp;alt=" "&nbsp;click=" "&nbsp;style=" "&nbsp;type=" "&nbsp;value=" "&nbsp;/&gt;</div>
<div></div>
<div>提示：</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;这个标记增加了鼠标移上和移除的滤镜效果,推荐使用,不过内部实现是有问题的,如果需要使用的同志,请修改一下TagLibHtml.class.php 125行</div>
<div>$parseStr &nbsp; = '&lt;span class="'.$style.'" &gt;&lt;input title="'.$alt.'" type="'.$type.'" id="'.$id.'" &nbsp;name="'.$name.'" onmouseover="this.style.filter=/'alpha(opacity=100)/'" onmouseout="this.style.filter=/'alpha(opacity=80)/'" onclick="'.$click.'" align="absmiddle" class="'.$name.' value="'.$value.'"&gt;&lt;/span&gt;';</div>
<div></div>
<div>属性：</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;id属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input的id值</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;name属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input的name值</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;alt属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input的title值</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;style属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input标记外面生成的span的样式</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;click属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input的click执行内容,可以为js语句块,也可以为js函数</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;type属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input属性的类别,如果不输入则默认为button</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;value属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input 的value的值,不过在源代码里面并未使用</div>
<div></div>
<div>select标记</div>
<div></div>
<div>&lt;html:select&nbsp;options=" "&nbsp;selected=" "&nbsp;id=" "&nbsp;name=" "&nbsp;values=" "&nbsp;output=" "&nbsp;multiple=" "&nbsp;size=" "&nbsp;first=" "&nbsp;style=" "&nbsp;dblclick=" "&nbsp;change=" "&nbsp;/&gt;</div>
<div></div>
<div>属性：</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;id属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select的id值</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;name属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select的name值</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dblclick属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select 双击事件调用的js</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;change属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select value值改变调用的js</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;multiple属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select 是否以可以选择多项 值不固定,任意值均可</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;style属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select 的样式</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;size属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select 的行数</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;first属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select 的第一个值,比如 请选择您的学历</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;options属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select的项,为php的有键的数组,如果没有键的数组请使用values属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;当两个属性同时存在时,以options为优先</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;value的值为$key</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;values属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select的项,为php无键的数组,当两个属性同时存在时,以options为优先</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;value的值为数组的值</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;selected属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select 默认的选中项</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;当使用options属时,selected属性的内容与$key进行匹配,如果使用values属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;则与内容进行匹配</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;output属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select option项目的结尾串,比如&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;option value=&#8221;1&#8221;&gt;小学学历&lt;/option&gt;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;option value=&#8221;2&#8221;&gt;中学学历&lt;/option&gt;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;option value=&#8221;3&#8221;&gt;大学学历&lt;/option&gt;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;这里的情况,我们就可以直接设置output为 学历</div>
<div></div>
<div></div>
<div></div>
<div>checkbox标签</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;html:checkbox&nbsp;checkboxes=" "&nbsp;checked=" "&nbsp;name=" "&nbsp;separator=" "&nbsp;/&gt;</div>
<div>提示：</div>
<div>checkboxes="" 请注意看这个属性 并不是checkboxs 在s的前面多了一个e</div>
<div>我想应该是官方手误吧,如果你愿意,请修改源码,或者说在使用的时候加上e</div>
<div>属性：</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;name属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;checkbox属性的name值,无论你输入什么,系统会默认增加[]</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;checkboxes</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;checkbox组,是php的有键数组(必须为有键数组),$key为checkbox项的value</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$value 为checkbox后面带的说明</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;checked</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;这里可以为数组,也可以为单个字符串</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果为字符串,则与$key进行匹配 判断是否选中</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果为数组,则匹配是否包含这个$key 判断是否选中</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;separator</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;分隔符,当一个checkbox项结束后的分隔符</div>
<div></div>
<div></div>
<div>radio标签</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;html:radio&nbsp;radios=" "&nbsp;checked=" "&nbsp;checked=" "&nbsp;separator=" "&nbsp;/&gt;</div>
<div>属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;radios</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;radio组是php的有键数组(必须为有键数组),$key为radio项的value</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$value 为radio后面带的说明</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;checked</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;这里可以为数组,也可以为单个字符串</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果为字符串,则与$key进行匹配 判断是否选中</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;name属性</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;radio属性的name值,无论你输入什么,系统会默认增加[]</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;separator</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;分隔符,当一个radio项结束后的分隔符</div>
<div></div>
<div>
<div>link标签解析</div>
<div>* 格式： &lt;html:link file="" type="" /&gt;</div>
<div>加载外部文件,type为文件类型(可选,建议填上),JS和CSS</div></div> <img src ="http://www.blogjava.net/lyjjq/aggbug/362377.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-10-31 15:15 <a href="http://www.blogjava.net/lyjjq/articles/362377.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>php 的编译</title><link>http://www.blogjava.net/lyjjq/articles/355656.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Wed, 03 Aug 2011 04:01:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/355656.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/355656.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/355656.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/355656.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/355656.html</trackback:ping><description><![CDATA['./configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--disable-cgi' '--enable-magic-quotes' '--disable-ipv6' '--with-openssl' '--with-zlib' '--with-bz2' '--enable-calendar' '--with-curl' '--enable-exif' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--enable-gd-native-ttf' '--enable-mbstring' '--with-mysql=/usr/local/mysql' '--with-pdo-mysql=/usr/local/mysql' '--with-pdo-dblib=/usr/local' '--with-mssql=/usr/local' '--without-pdo-sqlite' '--without-sqlite' '--without-sqlite3' '--enable-soap' '--enable-zip' '--with-pear' <img src ="http://www.blogjava.net/lyjjq/aggbug/355656.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-08-03 12:01 <a href="http://www.blogjava.net/lyjjq/articles/355656.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>phpMyAdmin  配置文件</title><link>http://www.blogjava.net/lyjjq/articles/352327.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Wed, 15 Jun 2011 01:09:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/352327.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/352327.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/352327.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/352327.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/352327.html</trackback:ping><description><![CDATA[<font face="Verdana">路径:/phpmyadmin/config.inc.php<br />$i++;<br />/* Authentication type */<br />$cfg['Servers'][$i]['auth_type'] = 'cookie';<br />/* Server parameters */<br />$cfg['Servers'][$i]['host'] = '192.168.10.21';<br />$cfg['Servers'][$i]['connect_type'] = 'tcp';<br />$cfg['Servers'][$i]['compress'] = false;<br />/* Select mysqli if your server has it */<br />$cfg['Servers'][$i]['extension'] = 'mysql';<br />$cfg['Servers'][$i]['AllowNoPassword'] = true;</font><img src ="http://www.blogjava.net/lyjjq/aggbug/352327.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-06-15 09:09 <a href="http://www.blogjava.net/lyjjq/articles/352327.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>memcache 和 php支持安装</title><link>http://www.blogjava.net/lyjjq/articles/348857.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Sat, 23 Apr 2011 02:11:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/348857.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/348857.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/348857.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/348857.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/348857.html</trackback:ping><description><![CDATA[<div class="line"></div>
<div class="entry">
<p>memcache是个很方便的东东，可以支持数据的频繁读写，效率比数据库要快，memcache的官方地址是http://memcached.org/</p>
<p>一、安装libevent支持</p>
<p>cd /usr/local/src/我习惯将代码文件放这里，整洁些<br />
wget http://www.monkey.org/~provos/libevent-1.2.tar.gz<br />
tar xzvf libevent-1.2.tar.gz<br />
cd libevent-1.2<br />
./configure &#8211;prefix=/usr<br />
make&amp;&amp;make install</p>
<p>二、安装memcached<br />
wget http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz<br />
tar xzvf memcached-1.4.4.tar.gz<br />
cd memcached-1.4.4<br />
./configure &#8211;with-libevent=/usr<br />
make<br />
make install</p>
<p>三、安装memcache的php支持<br />
wget http://pecl.php.net/get/memcache-2.2.5.tgz<br />
tar xzvf memcache-2.2.5.tgz<br />
cd memcache-2.2.5<br />
phpize<br />
./configure<br />
make<br />
make install<br />
#此时会提示你so文件安装在/usr/local/lib/php/extensions/no-debug-non-zts-20090626/下<br />
cp /usr/local/lib/php/extensions/no-debug-non-zts-20090626/memcache.so /usr/lib/php/modules/<br />
注意，/usr/lib/php/modules/是值php.ini中默认的extension_dir所指，因机器而异<br />
vi /etc/php.ini<br />
打开php配置文件，将下面的文本加到末尾<br />
extension=memcache.so<br />
[Memcache]<br />
memcache.allow_failover = On<br />
memcache.max_failover_attempts = 20<br />
memcache.chunk_size = 8192<br />
memcache.default_port = 11211<br />
;memcache.hash_strategy = &#8220;standard&#8221;<br />
;memcache.hash_function = &#8220;crc32&#8243;<br />
此时重启apache看phpinfo就可看到memcache具体条目</p>
<p>四、启动memcached服务<br />
/usr/local/bin/memcached -d -m 10 -u nobody -l 127.0.0.1 -p 12000 -c 256 -P /tmp/memcached.pid<br />
最好将这句话加到 /etc/rc.local 中<br />
-d选项是启动一个守护进程，<br />
-m是分配给Memcache使用的内存数量，单位是MB，我这里是10MB，<br />
-u是运行Memcache的用户，为了安全，nobody即可<br />
-l是监听的服务器IP地址，如果有多个地址的话，我这里指定了服务器的回环地址，<br />
-p是设置Memcache监听的端口，我这里设置了12000，最好是1024以上的端口，<br />
-c选项是最大运行的并发连接数，默认是1024，我这里设置了256，按照你服务器的负载量来设定，<br />
-P是设置保存Memcache的pid文件，我这里是保存在 /tmp/memcached.pid，</p>
<p>五、测试文件<br />
<?php<br />
$mem = new Memcache;<br />
$mem-&gt;connect(&#8220;127.0.0.1&#8243;, 12000);<br />
$mem-&gt;set(&#8216;key&#8217;, &#8216;Welcom to shallwe.net !&#8217;, 0, 60);<br />
$val = $mem-&gt;get(&#8216;key&#8217;);<br />
echo $val;<br />
?&gt;<br />
</p>
</div>
<img src ="http://www.blogjava.net/lyjjq/aggbug/348857.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-04-23 10:11 <a href="http://www.blogjava.net/lyjjq/articles/348857.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ThinkPHP示例之：调试方法</title><link>http://www.blogjava.net/lyjjq/articles/348849.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Sat, 23 Apr 2011 01:14:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/348849.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/348849.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/348849.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/348849.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/348849.html</trackback:ping><description><![CDATA[<pre>halt($msg)  //输出错误信息，并中止执行
system_out($msg) //输出调试信息到日志文件
dump($var, $echo=true, $label=null)  //输出变量信息
get_include_contents($filename) //获取载入文件的内容<br />
</pre>
<pre>debug_start($label='') //记录调试开始时间
debug_end($label='')  //输出调试范围运行时间（相同label属于一个调试范围）
</pre>
<pre>更高级的调试方法是使用Debug类
Debug::mark($name); // 标记一个调试位置
Debug::useTime($start,$end); // 返回区间所用的时间
Debug::useMemory($start,$end); // 返回区间所用的内存
</pre>
<img src ="http://www.blogjava.net/lyjjq/aggbug/348849.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-04-23 09:14 <a href="http://www.blogjava.net/lyjjq/articles/348849.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>THINKPHP扩展类：log类的使用</title><link>http://www.blogjava.net/lyjjq/articles/348848.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Sat, 23 Apr 2011 01:13:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/348848.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/348848.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/348848.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/348848.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/348848.html</trackback:ping><description><![CDATA[<div class="t_fsz">
<table cellspacing="0" cellpadding="0">
    <tbody>
        <tr>
            <td id="postmessage_208" class="t_f">[ 概述 ]<br />
            ThinkPHP内置了日志处理类，无需导入就可以直接使用。Log类提供了包括记录系统异常和错误和调试信息，以及SQL信息等功能，日志文件分别对应为WEB_LOG_ERROR 、WEB_LOG_DEBUG和SQL_LOG_DEBUG三种类型，对应的日志文件名称为：<br />
            systemErr.log主要用于WEB_LOG_ERROR类型日志<br />
            用于记录系统异常，通常为抛出异常或者捕获严重错误后自动记录<br />
            systemOut.log主要用于WEB_LOG_DEBUG日志类型<br />
            用于记录调试信息和页面的一些非严重错误记录，调试信息一般为system_out方法写入。<br />
            systemSql.log 主要是用于SQL_LOG_DEBUG日志类型<br />
            记录执行过程中的SQL语句和执行时间，便于进行分析和优化。<br />
            日志文件的命名规则是前面增加日期前缀，原则上是一天的同类型的日志记录在一个文件里面，您可以随时查看日志文件,例如：
            <ul class="litype_1" type="1">
                <li>07_09_21_systemOut.log&nbsp;&nbsp;// 2007年9月21日的错误日志文件
                <li>07_12_03_systemSql.log&nbsp;&nbsp;// 2007年12月3日的SQL日志文件
                <li>07_02_03_systemErr.log&nbsp;&nbsp;// 2007年2月3日的异常日志文件<br />
                </li>
            </ul>
            <br />
            <em>复制代码</em><br />
            相关配置
            <ul class="litype_1" type="1">
                <li>'WEB_LOG_RECORD'&nbsp; &nbsp;=&gt; false,&nbsp;&nbsp;// 默认不记录日志
                <li>'LOG_FILE_SIZE'&nbsp; &nbsp; =&gt; 2097152, // 日志文件大小限制<br />
                </li>
            </ul>
            <br />
            <em>复制代码</em><br />
            设置WEB_LOG_RECORD为true就可以启用日志记录功能，可以设置LOG_FILE_SIZE参数来限制日志文件的大小，超过大小的日志会形成备份文件。备份文件的格式是在当前文件名前面加上备份的时间戳，例如：<br />
            1189571417-07_09_12_systemSql.log 备份的SQL日志文件<br />
            在系统的调试模式中，系统的所有异常和错误都会记录到系统日志中，在正式部署应用后，您可以关闭调试模式，这样系统就不会自动完成日志记录，除非你自己触发日志写入。 <br />
            系统对每个项目单独记录日志，所以查看的时候请注意定位到某个项目目录下。<br />
            如果您的应用组件需要记录特殊的日志，也可以调用（或者扩展）该方法来完成。<br />
            <br />
            [ 方法 ]<br />
            Log类提供了三个静态方法<br />
            <font color="blue">Log::record($message,$type=WEB_LOG_ERROR)</font><br />
            记录Log信息和类型 默认是错误日志类型<br />
            <font color="blue">Log::save()</font> <br />
            把record方法记录的日志信息统一保存到文件<br />
            <font color="blue">Log::write($message,$type=WEB_LOG_ERROR,$file='')</font><br />
            直接写入日志信息<br />
            $message 是要记录的日志信息<br />
            $type 就是日志类型<br />
            $file 日志文件位置和名称，该参数可以改变系统默认的日志文件命名。<br />
            <br />
            <br />
            [ 示例 ]<br />
            Log类使用的简单例子：
            <ul class="litype_1" type="1">
                <li>// 记录日志信息 但是不保存到文件
                <li>Log::record('用户数据错误');
                <li>Log::record('保存用户信息发生异常',WEB_LOG_ERROR);
                <li>// 把上面的日志信息写入文件保存
                <li>Log::save();
                <li>// 直接写入日志文件
                <li>Log::write('这里记录一下',WEB_LOG_DEBUG);<br />
                </li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
</div>
<img src ="http://www.blogjava.net/lyjjq/aggbug/348848.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-04-23 09:13 <a href="http://www.blogjava.net/lyjjq/articles/348848.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>php 取日期函数</title><link>http://www.blogjava.net/lyjjq/articles/348837.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Fri, 22 Apr 2011 13:24:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/348837.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/348837.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/348837.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/348837.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/348837.html</trackback:ping><description><![CDATA[&lt;?php echo $showtime=date("Y-m-d H:i:s");?&gt; <br />
显示的格式: 年-月-日 小时:分钟:妙 <br />
相关时间参数: <br />
a - "am" 或是 "pm" <br />
A - "AM" 或是 "PM" <br />
d - 几日，二位数字，若不足二位则前面补零; 如: "01" 至 "31" <br />
D - 星期几，三个英文字母; 如: "Fri" <br />
F - 月份，英文全名; 如: "January" <br />
h - 12 小时制的小时; 如: "01" 至 "12" <br />
H - 24 小时制的小时; 如: "00" 至 "23" <br />
g - 12 小时制的小时，不足二位不补零; 如: "1" 至 12" <br />
G - 24 小时制的小时，不足二位不补零; 如: "0" 至 "23" <br />
i - 分钟; 如: "00" 至 "59" <br />
j - 几日，二位数字，若不足二位不补零; 如: "1" 至 "31" <br />
l - 星期几，英文全名; 如: "Friday" <br />
m - 月份，二位数字，若不足二位则在前面补零; 如: "01" 至 "12" <br />
n - 月份，二位数字，若不足二位则不补零; 如: "1" 至 "12" <br />
M - 月份，三个英文字母; 如: "Jan" <br />
s - 秒; 如: "00" 至 "59" <br />
S - 字尾加英文序数，二个英文字母; 如: "th"，"nd" <br />
t - 指定月份的天数; 如: "28" 至 "31" <br />
U - 总秒数 <br />
w - 数字型的星期几，如: "0" (星期日) 至 "6" (星期六) <br />
Y - 年，四位数字; 如: "1999" <br />
y - 年，二位数字; 如: "99" <br />
z - 一年中的第几天; 如: "0" 至 "365"
 <img src ="http://www.blogjava.net/lyjjq/aggbug/348837.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-04-22 21:24 <a href="http://www.blogjava.net/lyjjq/articles/348837.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Php字符串函数</title><link>http://www.blogjava.net/lyjjq/articles/348766.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Fri, 22 Apr 2011 01:48:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/348766.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/348766.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/348766.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/348766.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/348766.html</trackback:ping><description><![CDATA[<table border="0" width="100%">
    <tbody>
        <tr>
            <td valign="top" align="right"><a href="function.php-AddSlashes.htm" alt="function.php?AddSlashes">AddSlashes</a>:</td>
            <td valign="top">字符串加入斜线。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-bin2hex.htm" alt="function.php?bin2hex">bin2hex</a>:</td>
            <td valign="top">二进位转成十六进位。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-Chop.htm" alt="function.php?Chop">Chop</a>:</td>
            <td valign="top">去除连续空白。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-Chr.htm" alt="function.php?Chr">Chr</a>:</td>
            <td valign="top">返回序数值的字符。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-chunk_split.htm" alt="function.php?chunk_split">chunk_split</a>:</td>
            <td valign="top">将字符串分成小段。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-convert_cyr_string.htm" alt="function.php?convert_cyr_string">convert_cyr_string</a>:</td>
            <td valign="top">转换古斯拉夫字符串成其它字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-crypt.htm" alt="function.php?crypt">crypt</a>:</td>
            <td valign="top">将字符串用 DES 编码加密。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-echo.htm" alt="function.php?echo">echo</a>:</td>
            <td valign="top">输出字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-explode.htm" alt="function.php?explode">explode</a>:</td>
            <td valign="top">切开字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-flush.htm" alt="function.php?flush">flush</a>:</td>
            <td valign="top">清出输出缓冲区。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-get_meta_tags.htm" alt="function.php?get_meta_tags">get_meta_tags</a>:</td>
            <td valign="top">抽出文件所有 meta 标记的资料。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-htmlspecialchars.htm" alt="function.php?htmlspecialchars">htmlspecialchars</a>:</td>
            <td valign="top">将特殊字符转成 HTML 格式。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-htmlentities.htm" alt="function.php?htmlentities">htmlentities</a>:</td>
            <td valign="top">将所有的字符都转成 HTML 字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-implode.htm" alt="function.php?implode">implode</a>:</td>
            <td valign="top">将数组变成字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-join.htm" alt="function.php?join">join</a>:</td>
            <td valign="top">将数组变成字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-ltrim.htm" alt="function.php?ltrim">ltrim</a>:</td>
            <td valign="top">去除连续空白。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-md5.htm" alt="function.php?md5">md5</a>:</td>
            <td valign="top">计算字符串的 MD5 哈稀。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-nl2br.htm" alt="function.php?nl2br">nl2br</a>:</td>
            <td valign="top">将换行字符转成 &lt;br&gt;。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-Ord.htm" alt="function.php?Ord">Ord</a>:</td>
            <td valign="top">返回字符的序数值。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-parse_str.htm" alt="function.php?parse_str">parse_str</a>:</td>
            <td valign="top">解析 query 字符串成变量。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-print.htm" alt="function.php?print">print</a>:</td>
            <td valign="top">输出字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-printf.htm" alt="function.php?printf">printf</a>:</td>
            <td valign="top">输出格式化字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-quoted_printable_decode.htm" alt="function.php?quoted_printable_decode">quoted_printable_decode</a>:</td>
            <td valign="top">将 qp 编码字符串转成 8 位字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-QuoteMeta.htm" alt="function.php?QuoteMeta">QuoteMeta</a>:</td>
            <td valign="top">加入引用符号。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-rawurldecode.htm" alt="function.php?rawurldecode">rawurldecode</a>:</td>
            <td valign="top">从 URL 专用格式字符串还原成普通字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-rawurlencode.htm" alt="function.php?rawurlencode">rawurlencode</a>:</td>
            <td valign="top">将字符串编码成 URL 专用格式。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-setlocale.htm" alt="function.php?setlocale">setlocale</a>:</td>
            <td valign="top">配置地域化信息。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-similar_text.htm" alt="function.php?similar_text">similar_text</a>:</td>
            <td valign="top">计算字符串相似度。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-soundex.htm" alt="function.php?soundex">soundex</a>:</td>
            <td valign="top">计算字符串的读音值</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-sprintf.htm" alt="function.php?sprintf">sprintf</a>:</td>
            <td valign="top">将字符串格式化。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strchr.htm" alt="function.php?strchr">strchr</a>:</td>
            <td valign="top">寻找第一个出现的字符。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strcmp.htm" alt="function.php?strcmp">strcmp</a>:</td>
            <td valign="top">字符串比较。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strcspn.htm" alt="function.php?strcspn">strcspn</a>:</td>
            <td valign="top">不同字符串的长度。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strip_tags.htm" alt="function.php?strip_tags">strip_tags</a>:</td>
            <td valign="top">去掉 HTML 及 PHP 的标记。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-StripSlashes.htm" alt="function.php?StripSlashes">StripSlashes</a>:</td>
            <td valign="top">去掉反斜线字符。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strlen.htm" alt="function.php?strlen">strlen</a>:</td>
            <td valign="top">取得字符串长度。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strrpos.htm" alt="function.php?strrpos">strrpos</a>:</td>
            <td valign="top">寻找字符串中某字符最后出现处。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strpos.htm" alt="function.php?strpos">strpos</a>:</td>
            <td valign="top">寻找字符串中某字符最先出现处。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strrchr.htm" alt="function.php?strrchr">strrchr</a>:</td>
            <td valign="top">取得某字符最后出现处起的字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strrev.htm" alt="function.php?strrev">strrev</a>:</td>
            <td valign="top">颠倒字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strspn.htm" alt="function.php?strspn">strspn</a>:</td>
            <td valign="top">找出某字符串落在另一字符串遮罩的数目。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strstr.htm" alt="function.php?strstr">strstr</a>:</td>
            <td valign="top">返回字符串中某字符串开始处至结束的字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strtok.htm" alt="function.php?strtok">strtok</a>:</td>
            <td valign="top">切开字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strtolower.htm" alt="function.php?strtolower">strtolower</a>:</td>
            <td valign="top">字符串全转为小写。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strtoupper.htm" alt="function.php?strtoupper">strtoupper</a>:</td>
            <td valign="top">字符串全转为大写。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-str_replace.htm" alt="function.php?str_replace">str_replace</a>:</td>
            <td valign="top">字符串取代。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-strtr.htm" alt="function.php?strtr">strtr</a>:</td>
            <td valign="top">转换某些字符。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-substr.htm" alt="function.php?substr">substr</a>:</td>
            <td valign="top">取部份字符串。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-trim.htm" alt="function.php?trim">trim</a>:</td>
            <td valign="top">截去字符串首尾的空格。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-ucfirst.htm" alt="function.php?ucfirst">ucfirst</a>:</td>
            <td valign="top">将字符串第一个字符改大写。</td>
        </tr>
        <tr>
            <td valign="top" align="right"><a href="function.php-ucwords.htm" alt="function.php?ucwords">ucwords</a>:</td>
            <td valign="top">将字符串每个字第一个字母改大写。</td>
        </tr>
    </tbody>
</table>
<img src ="http://www.blogjava.net/lyjjq/aggbug/348766.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-04-22 09:48 <a href="http://www.blogjava.net/lyjjq/articles/348766.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>php生成excel</title><link>http://www.blogjava.net/lyjjq/articles/345958.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Tue, 08 Mar 2011 09:57:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/345958.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/345958.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/345958.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/345958.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/345958.html</trackback:ping><description><![CDATA[<p>&lt;?php</p>
<p>include 'Lib/PhpExcel/PHPExcel.php';<br />
include 'Lib/PhpExcel/PHPExcel/Writer/Excel5.php';</p>
<p>// uncomment&nbsp;&nbsp; <br />
////require_once 'PHPExcel/Writer/Excel5.php';&nbsp;&nbsp;&nbsp; // 用于其他低版本xls&nbsp;&nbsp; <br />
// or&nbsp;&nbsp; <br />
////require_once 'PHPExcel/Writer/Excel2007.php'; // 用于 excel-2007 格式&nbsp;&nbsp; </p>
<p>// 创建一个处理对象实例&nbsp;&nbsp; <br />
$objExcel = new PHPExcel();</p>
<p>// 创建文件格式写入对象实例, uncomment&nbsp;&nbsp; <br />
$objWriter = new PHPExcel_Writer_Excel5($objExcel);&nbsp;&nbsp;&nbsp; // 用于其他版本格式&nbsp;&nbsp; <br />
// or&nbsp;&nbsp; <br />
//$objWriter = new PHPExcel_Writer_Excel2007($objExcel); // 用于 2007 格式&nbsp;&nbsp; <br />
//$objWriter-&gt;setOffice2003Compatibility(true);&nbsp;&nbsp; </p>
<p>//*************************************&nbsp;&nbsp; <br />
//设置文档基本属性&nbsp;&nbsp; <br />
$objProps = $objExcel-&gt;getProperties();<br />
$objProps-&gt;setCreator("Zeal Li");<br />
$objProps-&gt;setLastModifiedBy("Zeal Li");<br />
$objProps-&gt;setTitle("Office XLS Test Document");<br />
$objProps-&gt;setSubject("Office XLS Test Document, Demo");<br />
$objProps-&gt;setDescription("Test document, generated by PHPExcel.");<br />
$objProps-&gt;setKeywords("office excel PHPExcel");<br />
$objProps-&gt;setCategory("Test");</p>
<p>//*************************************&nbsp;&nbsp; <br />
//设置当前的sheet索引，用于后续的内容操作。&nbsp;&nbsp; <br />
//一般只有在使用多个sheet的时候才需要显示调用。&nbsp;&nbsp; <br />
//缺省情况下，PHPExcel会自动创建第一个sheet被设置SheetIndex=0&nbsp;&nbsp; <br />
$objExcel-&gt;setActiveSheetIndex(0);</p>
<p>$objActSheet = $objExcel-&gt;getActiveSheet();</p>
<p>//设置当前活动sheet的名称&nbsp;&nbsp; <br />
$objActSheet-&gt;setTitle('测试Sheet');</p>
<p>//*************************************&nbsp;&nbsp; <br />
//设置单元格内容&nbsp;&nbsp; <br />
//&nbsp;&nbsp; <br />
//由PHPExcel根据传入内容自动判断单元格内容类型&nbsp;&nbsp; <br />
$objActSheet-&gt;setCellValue('A1', '字符串内容'); // 字符串内容&nbsp;&nbsp; <br />
$objActSheet-&gt;setCellValue('A2', 26); // 数值&nbsp;&nbsp; <br />
$objActSheet-&gt;setCellValue('A3', true); // 布尔值&nbsp;&nbsp; <br />
$objActSheet-&gt;setCellValue('A4', '=SUM(A2:A2)'); // 公式&nbsp;&nbsp; </p>
<p>//显式指定内容类型&nbsp;&nbsp; <br />
$objActSheet-&gt;setCellValueExplicit('A5', '847475847857487584', PHPExcel_Cell_DataType :: TYPE_STRING);</p>
<p>//合并单元格&nbsp;&nbsp; <br />
$objActSheet-&gt;mergeCells('B1:C22');</p>
<p>//分离单元格&nbsp;&nbsp; <br />
$objActSheet-&gt;unmergeCells('B1:C22');</p>
<p>//*************************************&nbsp;&nbsp; <br />
//设置单元格样式&nbsp;&nbsp; <br />
//&nbsp;&nbsp; </p>
<p>//设置宽度&nbsp;&nbsp; <br />
$objActSheet-&gt;getColumnDimension('B')-&gt;setAutoSize(true);<br />
$objActSheet-&gt;getColumnDimension('A')-&gt;setWidth(30);</p>
<p>$objStyleA5 = $objActSheet-&gt;getStyle('A5');</p>
<p>//设置单元格内容的数字格式。&nbsp;&nbsp; <br />
//&nbsp;&nbsp; <br />
//如果使用了 PHPExcel_Writer_Excel5 来生成内容的话，&nbsp;&nbsp; <br />
//这里需要注意，在 PHPExcel_Style_NumberFormat 类的 const 变量定义的&nbsp;&nbsp; <br />
//各种自定义格式化方式中，其它类型都可以正常使用，但当setFormatCode&nbsp;&nbsp; <br />
//为 FORMAT_NUMBER 的时候，实际出来的效果被没有把格式设置为"0"。需要&nbsp;&nbsp; <br />
//修改 PHPExcel_Writer_Excel5_Format 类源代码中的 getXf($style) 方法，&nbsp;&nbsp; <br />
//在 if ($this-&gt;_BIFF_version == 0x0500) { （第363行附近）前面增加一&nbsp;&nbsp; <br />
//行代码:&nbsp;&nbsp;&nbsp; <br />
//if($ifmt === '0') $ifmt = 1;&nbsp;&nbsp; <br />
//&nbsp;&nbsp; <br />
//设置格式为PHPExcel_Style_NumberFormat::FORMAT_NUMBER，避免某些大数字&nbsp;&nbsp; <br />
//被使用科学记数方式显示，配合下面的 setAutoSize 方法可以让每一行的内容&nbsp;&nbsp; <br />
//都按原始内容全部显示出来。&nbsp;&nbsp; <br />
$objStyleA5-&gt;getNumberFormat()-&gt;setFormatCode(PHPExcel_Style_NumberFormat :: FORMAT_NUMBER);</p>
<p>//设置字体&nbsp;&nbsp; <br />
$objFontA5 = $objStyleA5-&gt;getFont();<br />
$objFontA5-&gt;setName('Courier New');<br />
$objFontA5-&gt;setSize(10);<br />
$objFontA5-&gt;setBold(true);<br />
$objFontA5-&gt;setUnderline(PHPExcel_Style_Font :: UNDERLINE_SINGLE);<br />
$objFontA5-&gt;getColor()-&gt;setARGB('FF999999');</p>
<p>//设置对齐方式&nbsp;&nbsp; <br />
$objAlignA5 = $objStyleA5-&gt;getAlignment();<br />
$objAlignA5-&gt;setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_RIGHT);<br />
$objAlignA5-&gt;setVertical(PHPExcel_Style_Alignment :: VERTICAL_CENTER);</p>
<p>//设置边框&nbsp;&nbsp; <br />
$objBorderA5 = $objStyleA5-&gt;getBorders();<br />
$objBorderA5-&gt;getTop()-&gt;setBorderStyle(PHPExcel_Style_Border :: BORDER_THIN);<br />
$objBorderA5-&gt;getTop()-&gt;getColor()-&gt;setARGB('FFFF0000'); // color&nbsp;&nbsp; <br />
$objBorderA5-&gt;getBottom()-&gt;setBorderStyle(PHPExcel_Style_Border :: BORDER_THIN);<br />
$objBorderA5-&gt;getLeft()-&gt;setBorderStyle(PHPExcel_Style_Border :: BORDER_THIN);<br />
$objBorderA5-&gt;getRight()-&gt;setBorderStyle(PHPExcel_Style_Border :: BORDER_THIN);</p>
<p>//设置填充颜色&nbsp;&nbsp; <br />
$objFillA5 = $objStyleA5-&gt;getFill();<br />
$objFillA5-&gt;setFillType(PHPExcel_Style_Fill :: FILL_SOLID);<br />
$objFillA5-&gt;getStartColor()-&gt;setARGB('FFEEEEEE');</p>
<p>//从指定的单元格复制样式信息.&nbsp;&nbsp; <br />
$objActSheet-&gt;duplicateStyle($objStyleA5, 'B1:C22');</p>
<p><br />
//添加一个新的worksheet&nbsp;&nbsp; <br />
$objExcel-&gt;createSheet();<br />
$objExcel-&gt;getSheet(1)-&gt;setTitle('测试2');</p>
<p>//保护单元格&nbsp;&nbsp; <br />
$objExcel-&gt;getSheet(1)-&gt;getProtection()-&gt;setSheet(true);<br />
$objExcel-&gt;getSheet(1)-&gt;protectCells('A1:C22', 'PHPExcel');</p>
<p>//*************************************&nbsp;&nbsp; <br />
//输出内容&nbsp;&nbsp; <br />
//&nbsp;&nbsp; <br />
$outputFileName = "output.xls";<br />
//到文件&nbsp;&nbsp; <br />
//$objWriter-&gt;save($outputFileName);&nbsp;&nbsp; <br />
//or&nbsp;&nbsp; <br />
//到浏览器&nbsp;&nbsp; <br />
header('Content-type:aplication/vnd.ms-excel');<br />
header("Content-Disposition: attachment; filename=out.xls");<br />
$objWriter-&gt;save('php://output');<br />
?&gt;&nbsp;&nbsp; <br />
</p>
<img src ="http://www.blogjava.net/lyjjq/aggbug/345958.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-03-08 17:57 <a href="http://www.blogjava.net/lyjjq/articles/345958.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux Php连接SQLServer数据库(freetds)</title><link>http://www.blogjava.net/lyjjq/articles/345374.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Mon, 28 Feb 2011 14:03:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/345374.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/345374.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/345374.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/345374.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/345374.html</trackback:ping><description><![CDATA[由于工作原因我们需要通过<a title="PHP" href="http://security.zdnet.com.cn/files/list-0-0-49937-1-1.htm">PHP</a>访问我们以前的Sql Server 2005数据,所以就有了这篇文章的诞生.废话就少说了,做程序设计的最不喜欢兜圈子了.用简介步骤说明问题,往下看.
<p>　　系统: <a title="Linux" href="http://security.zdnet.com.cn/files/list-0-0-49050-1-1.htm">Linux</a></p>
<p>　　数据库: Sql Server 2005</p>
<p>　　1.下载FreeTDS</p>
<p>　　官方网站：http://www.freetds.org</p>
<p>　　2.安装FreeTDS</p>
<p>　　# tar zxvf freetds-current.tgz(解压)</p>
<p>　　# ./configure --prefix=/usr/local/freetds --with-tdsver=7.2 --enable-msdblib</p>
<p>　　# make</p>
<p>　　# make install</p>
<p>　　其他可选 根据自己情况</p>
<p>　　--enable-dbmfix --with-gnu-ld --enable-shared --enable-static</p>
<p>　　安装freetds到目录/usr/local/freetds：--prefix=/usr/local/freetds 如果不带这个默认好像也是这目录</p>
<p>　　对应数据库版本--我的是Microsoft SQL Server 2005 所以我带的是 --with-tdsver=7.2</p>
<p>　　4.2 Sybase SQL Server &lt; 10 and Microsoft SQL Server 6.5</p>
<p>　　5.0 Sybase SQL Server &gt;= 10</p>
<p>　　7.0 Microsoft SQL Server 7.0</p>
<p>　　7.1 Microsoft SQL Server 2000</p>
<p>　　7.2 Microsoft SQL Server 2005</p>
<p>　　3.编辑/usr/local/freetds/etc/freetds.conf</p>
<p>　　# $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $</p>
<p>　　#</p>
<p>　　# This file is installed by FreeTDS if no file by the same</p>
<p>　　# name is found in the installation directory.</p>
<p>　　#</p>
<p>　　# For information about the layout of this file and its settings,</p>
<p>　　# see the freetds.conf manpage "man freetds.conf".</p>
<p>　　# Global settings are overridden by those in a database</p>
<p>　　# server specific section</p>
<p>　　[global]</p>
<p>　　# TDS protocol version</p>
<p>　　; tds version = 4.2</p>
<p>　　# Whether to write a TDSDUMP file for diagnostic purposes</p>
<p>　　# (setting this to /tmp is insecure on a multi-user system)</p>
<p>　　; dump file = /tmp/freetds.log</p>
<p>　　; debug flags = 0xffff</p>
<p>　　# Command and connection timeouts</p>
<p>　　; timeout = 10</p>
<p>　　; connect timeout = 10</p>
<p>　　# If you get out-of-memory errors, it may mean that your client</p>
<p>　　# is trying to allocate a huge buffer for a TEXT field.</p>
<p>　　# Try setting "text size" to a more reasonable limit</p>
<p>　　text size = 64512</p>
<p>　　#解决中文乱码问题</p>
<p>　　client charset=utf8</p>
<p>　　# A typical Sybase server</p>
<p>　　#[egServer50]</p>
<p>　　# host = symachine.domain.com</p>
<p>　　# port = 5000</p>
<p>　　# tds version = 5.0</p>
<p>　　# A typical Microsoft server</p>
<p>　　#[egServer70]</p>
<p>　　# host = ntmachine.domain.com</p>
<p>　　# port = 1433</p>
<p>　　# tds version = 7.0</p>
<p>　　#这个名字程序和命令行用得上,叫什么自己定</p>
<p>　　[Server2005]</p>
<p>　　host = 192.168.3.100 #我的SQL Server2005 IP,根据自己改</p>
<p>　　port = 1433</p>
<p>　　tds version = 7.2</p>
<p>　　4.测试连接:</p>
<p>　　[root@test bin]# ./tsql -S Server2005 -p 1433 -U java -P java -D PublicDB</p>
<p>　　locale is "zh_CN"</p>
<p>　　locale charset is "GB2312"</p>
<p>　　Default database being set to PublicDB</p>
<p>　　1&gt;</p>
<p>　　出现这个表示连接成功! 退出:quit 和 exit 都行.</p>
<p>　　参数说明</p>
<p>　　-S 配置的服务名</p>
<p>　　-H 主机名</p>
<p>　　-p 端口</p>
<p>　　-U username</p>
<p>　　-P password</p>
<p>　　-D database</p>
<p>　　5.测试查询:</p>
<p>　　# ./tsql -S Server2005 -p 1433 -U java -P java -D PublicDB</p>
<p>　　1&gt; select USER_ID,TRUE_NAME from USER_INFO</p>
<p>　　2&gt; go</p>
<p>　　可以显示中文没问题!</p>
<p>　　6.让<a title="PHP" href="http://security.zdnet.com.cn/files/list-0-0-49937-1-1.htm">PHP</a>支持mssql(freeTDS)</p>
<p>　　重新编译<a title="PHP" href="http://security.zdnet.com.cn/files/list-0-0-49937-1-1.htm">PHP</a> 这些参数根据自己情况来定,下面是我们需要的</p>
<p>　　但是必须带--with-mssql=/usr/local/freetds</p>
<p>　　./configure --prefix=/usr/local/<a title="PHP" href="http://security.zdnet.com.cn/files/list-0-0-49937-1-1.htm">PHP</a> --with-<a title="MySQL" href="http://security.zdnet.com.cn/files/list-0-0-49513-1-1.htm">MySQL</a>=/usr/local/<a title="MySQL" href="http://security.zdnet.com.cn/files/list-0-0-49513-1-1.htm">MySQL</a> --with-apxs2=/usr/local/apache/bin/apxs --with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr/local/libpng --with-zlib-dir=/usr/local/zlib --with-libxml-dir=/usr/local/libxml2 --with-iconv=/usr/local/libiconv --with-freetype-dir=/usr/local/freetype --with-pdo-<a title="MySQL" href="http://security.zdnet.com.cn/files/list-0-0-49513-1-1.htm">MySQL</a>=/usr/local/<a title="PHP" href="http://security.zdnet.com.cn/files/list-0-0-49937-1-1.htm">PHP</a>bak/lib/<a title="PHP" href="http://security.zdnet.com.cn/files/list-0-0-49937-1-1.htm">PHP</a>/extensions/no-debug-non-zts-20060613/pdo_<a title="MySQL" href="http://security.zdnet.com.cn/files/list-0-0-49513-1-1.htm">MySQL</a>.so --enable-sockets --with-curl --with-pear --with-mssql=/usr/local/freetds</p>
<p>　　如果编译报错请执行:</p>
<p>　　# touch /usr/local/freetds/include/tds.h</p>
<p>　　# touch /usr/local/freetds/lib/libtds.a</p>
<p>　　7.<a title="PHP" href="http://security.zdnet.com.cn/files/list-0-0-49937-1-1.htm">PHP</a>测试程序</p>
<p>　　<?php</p>
<p>　　/**</p>
<p>　　* MOIT</p>
<p>　　*</p>
<p>　　* @author 明白(admin126com@126.com) 日 期: Wed Nov 18 05:00:07 GMT 2009</p>
<p>　　* @copyright Copyright (c) 2009</p>
<p>　　* @desc 测试</p>
<p>　　*/</p>
<p>　　$msconnect=mssql_connect("Server2005","java","java");</p>
<p>　　$msdb=mssql_select_db("PublicDB",$msconnect);</p>
<p>　　$msquery = "select TRUE_NAME,USER_ID,USER_NAME,PASSWORD from USER_INFO";</p>
<p>　　$msresults= mssql_query($msquery);</p>
<p>　　while ($row = mssql_fetch_array($msresults)) {</p>
<p>　　echo $row["USER_ID"] . " ".$row["TRUE_NAME"]. " " . $row["USER_NAME"] . " " . $row["PASSWORD"] . "<br />
";</p>
<p>　　}</p>
<p>　　?&gt;</p>
<p>　　8.安装完毕,祝您成功!</p>
  <img src ="http://www.blogjava.net/lyjjq/aggbug/345374.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-02-28 22:03 <a href="http://www.blogjava.net/lyjjq/articles/345374.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>让PHP程序永远在后台运行</title><link>http://www.blogjava.net/lyjjq/articles/342625.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Sun, 09 Jan 2011 09:12:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/342625.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/342625.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/342625.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/342625.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/342625.html</trackback:ping><description><![CDATA[<div class="bct fc05 fc11 nbw-blog ztag js-fs2">PHP里有个函数很有用。这是在最近的开发中才逐渐用到的。 <br />
int ignore_user_abort ( [bool setting] ) <br />
<p style="text-indent: 2em">这个函数的作用是指示服务器端在远程客户端关闭连接后是否继续执行下面的脚本。 </p>
<p style="text-indent: 2em">setting 参数是一个可选参数。如设置为True，则表示如果用户停止脚本运行，仍然不影响脚本的运行（即：脚本将持续执行）；如果设置为False，则表示当用户停止运行脚本程序时，脚本程序将停止运行。 </p>
<p style="text-indent: 2em">下面这个例子，在用户关闭浏览器后，该脚本仍然后在服务器上继续执行： </p>
<p>&lt;?php<br />
ignore_user_abort(); // 后台运行<br />
set_time_limit(0); // 取消脚本运行时间的超时上限<br />
do{<br />
sleep(60); // 休眠1分钟<br />
}while(true); </p>
<p>?&gt;<br />
除非在服务器上关闭这个程序，否则这断代码将永远执行下去。</p>
<p>-------------------------------------------------------------------------</p>
<p style="text-indent: 2em">&lt;?php<br />
&nbsp;&nbsp; ignore_user_abort(); // 后台运行<br />
&nbsp;&nbsp; set_time_limit(0); // 取消脚本运行时间的超时上限<br />
&nbsp;&nbsp; echo 'start.&lt;br/&gt;';<br />
&nbsp;&nbsp; while(!file_exists('close.txt')){<br />
&nbsp;&nbsp;&nbsp; $fp = fopen('test.txt','a+');<br />
&nbsp;&nbsp;&nbsp; fwrite($fp,date("Y-m-d H:i:s") . " 成功了！\r\n");<br />
&nbsp;&nbsp;&nbsp; fclose($fp);<br />
&nbsp;&nbsp;&nbsp; sleep(10);<br />
&nbsp;&nbsp; }<br />
&nbsp;&nbsp; echo 'end.&lt;br/&gt;';<br />
?&gt;</p>
</div>
<img src ="http://www.blogjava.net/lyjjq/aggbug/342625.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-01-09 17:12 <a href="http://www.blogjava.net/lyjjq/articles/342625.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>php中的 三个判断变量的函数 empty is_null, isset</title><link>http://www.blogjava.net/lyjjq/articles/342624.html</link><dc:creator>强强</dc:creator><author>强强</author><pubDate>Sun, 09 Jan 2011 09:05:00 GMT</pubDate><guid>http://www.blogjava.net/lyjjq/articles/342624.html</guid><wfw:comment>http://www.blogjava.net/lyjjq/comments/342624.html</wfw:comment><comments>http://www.blogjava.net/lyjjq/articles/342624.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lyjjq/comments/commentRss/342624.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lyjjq/services/trackbacks/342624.html</trackback:ping><description><![CDATA[<p>isset 判断变量是否已存在<br />
empty 判断变量是否为空或为0<br />
is_null 判断变量是否为NULL</p>
<table>
    <tbody>
        <tr>
            <th>变量</th>
            <th>empty</th>
            <th>is_null</th>
            <th>isset</th>
        </tr>
        <tr>
            <td>$a=&#8221;&#8221;</td>
            <td>true</td>
            <td>false</td>
            <td>true</td>
        </tr>
        <tr>
            <td>$a=null</td>
            <td>true </td>
            <td>true</td>
            <td>false</td>
        </tr>
        <tr>
            <td>var $a</td>
            <td>true</td>
            <td>true</td>
            <td>false</td>
        </tr>
        <tr>
            <td>$a=array()</td>
            <td>true</td>
            <td>false</td>
            <td>true</td>
        </tr>
        <tr>
            <td>$a=false</td>
            <td>true</td>
            <td>false</td>
            <td>true</td>
        </tr>
        <tr>
            <td>$a=15</td>
            <td>false</td>
            <td>false</td>
            <td>true</td>
        </tr>
        <tr>
            <td>$a=1</td>
            <td>false</td>
            <td>false</td>
            <td>true</td>
        </tr>
        <tr>
            <td>$a=0</td>
            <td>true</td>
            <td>false</td>
            <td>true</td>
        </tr>
        <tr>
            <td>$a=&#8221;0&#8221;</td>
            <td>true</td>
            <td>false</td>
            <td>true</td>
        </tr>
        <tr>
            <td>$a=&#8221;true&#8221; </td>
            <td>false</td>
            <td>false</td>
            <td>true</td>
        </tr>
        <tr>
            <td>$a=&#8221;false&#8221;</td>
            <td>false</td>
            <td>false</td>
            <td>true</td>
        </tr>
    </tbody>
</table>
 <img src ="http://www.blogjava.net/lyjjq/aggbug/342624.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lyjjq/" target="_blank">强强</a> 2011-01-09 17:05 <a href="http://www.blogjava.net/lyjjq/articles/342624.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>