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

<channel>
	<title>『博客·琼斯』 &#187; PHP &amp; Mysql</title>
	<atom:link href="http://shuai.be/topics/php-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://shuai.be</link>
	<description></description>
	<lastBuildDate>Thu, 03 May 2012 15:42:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>&#8220;奶瓶腿&#8221;不能正常工作的解决方法</title>
		<link>http://shuai.be/archives/php-large-integer-autoconversion/</link>
		<comments>http://shuai.be/archives/php-large-integer-autoconversion/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 02:42:50 +0000</pubDate>
		<dc:creator>Jones</dc:creator>
				<category><![CDATA[PHP & Mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://shuai.be/archives/php-large-integer-autoconversion/</guid>
		<description><![CDATA[前阵子发现奶瓶腿突然不能转发、回复和收藏了。一看URI，原来是由于status id位数太长，被自动转换为科学计数法形式（如1.234E+12）。当初还以为是Twitter API返回的id溢出了呢，今天才找到原因，原来是php.ini中设置的precision=12导致的，也就是php默认对于大于12位的整数，自动转换为科学计数法形式。 问题找到了，解决方法也就出来了： vi /usr/local/php/etc/php.ini 找到 precision = xx, 把值改成18以上，保存； 重启php /usr/local/php/sbin/php-fpm restart OK. PS: 自己架设奶瓶推的同学，请在common/menu.php里找到： &#60;img src=”http://img.tongji.linezing.com/1228959/tongji.gif” style=”display:none;” /&#62; 将它删除，你懂的。 延伸阅读： Include,require,include_once,require_once 谈谈PHP中单引号和双引号的区别 PHP三元运算符的用法]]></description>
			<content:encoded><![CDATA[<p>前阵子发现奶瓶腿突然不能转发、回复和收藏了。一看URI，原来是由于status id位数太长，被自动转换为科学计数法形式（如1.234E+12）。当初还以为是Twitter API返回的id溢出了呢，今天才找到原因，原来是<span class='wp_keywordlink_affiliate'><a href="http://shuai.be/tags/php/" title="查看 php 中的全部文章" target="_blank">php</a></span>.ini中设置的precision=12导致的，也就是<span class='wp_keywordlink_affiliate'><a href="http://shuai.be/tags/php/" title="查看 php 中的全部文章" target="_blank">php</a></span>默认对于大于12位的整数，自动转换为科学计数法形式。</p>
<p><span id="more-2368"></span></p>
<p>问题找到了，解决方法也就出来了：</p>
<blockquote><p>vi /usr/local/<span class='wp_keywordlink_affiliate'><a href="http://shuai.be/tags/php/" title="查看 php 中的全部文章" target="_blank">php</a></span>/etc/php.ini 找到 precision = xx, 把值改成18以上，保存；</p></blockquote>
<p>重启php</p>
<blockquote><p>/usr/local/php/sbin/php-fpm restart</p></blockquote>
<p>OK.</p>
<p>PS: 自己架设奶瓶推的同学，请在common/menu.php里找到：</p>
<blockquote><p>&lt;img src=”http://img.tongji.linezing.com/1228959/tongji.gif”  style=”display:none;” /&gt;</p></blockquote>
<p>将它删除，你懂的。</p>
<p><strong>延伸阅读：</strong><ol>
<li><a href='http://shuai.be/archives/include-require-once/' rel='bookmark' title='Include,require,include_once,require_once'>Include,require,include_once,require_once</a></li>
<li><a href='http://shuai.be/archives/php-quote-marks/' rel='bookmark' title='谈谈PHP中单引号和双引号的区别'>谈谈PHP中单引号和双引号的区别</a></li>
<li><a href='http://shuai.be/archives/php-simple-condition/' rel='bookmark' title='PHP三元运算符的用法'>PHP三元运算符的用法</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://shuai.be/archives/php-large-integer-autoconversion/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PHP Notice: undefined index 完美解决方法</title>
		<link>http://shuai.be/archives/php-undefined-index/</link>
		<comments>http://shuai.be/archives/php-undefined-index/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 14:29:05 +0000</pubDate>
		<dc:creator>Jones</dc:creator>
				<category><![CDATA[PHP & Mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://shuai.be/?p=2045</guid>
		<description><![CDATA[平时用$_GET[‘xx’] 取得参数值时，如果之前不加判断在未传进参数时会出现这样的警告: PHP Notice: undefined index xxx 虽然可以通过设置错误显示方式来隐藏这个提示，但是这样也有隐患，就是在服务器的日志中会记录这些提示，导致日志文件异常庞大！ 下面是引用网上流行的解决方法： 首先，这个不是错误，是warning。所以如果服务器不能改，每个变量使用前应当先定义。 方法1：服务器配置修改 修改php.ini配置文件，error_reporting = E_ALL &#038; ~E_NOTICE 方法2：对变量进行初始化，规范书写（比较烦琐，因为有大量的变量）。但还没有找到好定义方法，望大家指教 方法3：每个文件头部加上：error_reporting(0); 如果不行，只有打开php.ini,找到display_errors，设置为display_errors = Off。以后任何错误都不会提示。 方法4 ：做判断：isset($_GET["page"]) if-else判断 或者加上'@'表示这行如果有错误或是警告不要輸出 如：@$page=$_GET["page"] 方法5：file1.php文件把$xx变量付一个值，用post 传递给file2.php， 如果file2.php没有$xx的定义，而直接使用$yy=$xx; 系统就会报错："undifined variaable $xx", 如果file2.php的文件开始用$xx="";定义，那么file1.php的$xx值就传不过来了！ file2.php里可以这样 if(!isset($xx)) $xx=""; 但Jones认为，这些方法都不太方便。你不妨这样解决： 定义一个函数： function _get($str){ $val = !empty($_GET[$str]) ? $_GET[$str] : null; return $val; } 然后在用的时候，直接用 _get('str') 代替 $_GET['str'] 就行啦~ [...]]]></description>
			<content:encoded><![CDATA[<p>平时用$_GET[‘xx’] 取得参数值时，如果之前不加判断在未传进参数时会出现这样的警告:</p>
<blockquote><p> PHP Notice: undefined index xxx</p></blockquote>
<p>虽然可以通过设置错误显示方式来隐藏这个提示，但是这样也有隐患，就是在服务器的日志中会记录这些提示，导致日志文件异常庞大！<br />
下面是引用网上流行的解决方法：<br />
<span id="more-2045"></span></p>
<blockquote><p>首先，这个不是错误，是warning。所以如果服务器不能改，每个变量使用前应当先定义。</p>
<p>方法1：服务器配置修改<br />
修改<span class='wp_keywordlink_affiliate'><a href="http://shuai.be/tags/php/" title="查看 php 中的全部文章" target="_blank">php</a></span>.ini配置文件，error_reporting = E_ALL &#038; ~E_NOTICE</p>
<p>方法2：对变量进行初始化，规范书写（比较烦琐，因为有大量的变量）。但还没有找到好定义方法，望大家指教</p>
<p>方法3：每个文件头部加上：error_reporting(0); 如果不行，只有打开<span class='wp_keywordlink_affiliate'><a href="http://shuai.be/tags/php/" title="查看 php 中的全部文章" target="_blank">php</a></span>.ini,找到display_errors，设置为display_errors = Off。以后任何错误都不会提示。<br />
方法4 ：做判断：isset($_GET["page"])      if-else判断</p>
<p>或者加上'@'表示这行如果有错误或是警告不要輸出<br />
如：@$page=$_GET["page"]</p>
<p>方法5：file1.php文件把$xx变量付一个值，用post 传递给file2.php，<br />
如果file2.php没有$xx的定义，而直接使用$yy=$xx; 系统就会报错："undifined variaable $xx", 如果file2.php的文件开始用$xx="";定义，那么file1.php的$xx值就传不过来了！</p>
<p>file2.php里可以这样<br />
if(!isset($xx)) $xx="";</p></blockquote>
<p>但Jones认为，这些方法都不太方便。你不妨这样解决：</p>
<blockquote><p>定义一个函数：</p>
<pre style="font: 10pt Consolas, Courier New;">
<font color=#0000FF>function</font> _get($str){
    $val = !<font color=#FF0000>empty</font>($_GET[$str]) ? $_GET[$str] : null;
    <font color=#0000FF>return</font> $val;
}
</pre>
<p>然后在用的时候，直接用 <strong>_get('str')</strong> 代替 $_GET['str'] 就行啦~</p></blockquote>
<p>是不是很方便？</p>
<p><strong>延伸阅读：</strong><ol>
<li><a href='http://shuai.be/archives/include-require-once/' rel='bookmark' title='Include,require,include_once,require_once'>Include,require,include_once,require_once</a></li>
<li><a href='http://shuai.be/archives/php-quote-marks/' rel='bookmark' title='谈谈PHP中单引号和双引号的区别'>谈谈PHP中单引号和双引号的区别</a></li>
<li><a href='http://shuai.be/archives/php-simple-condition/' rel='bookmark' title='PHP三元运算符的用法'>PHP三元运算符的用法</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://shuai.be/archives/php-undefined-index/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>人间API研究手记之一：PHP对数组操作比读取数据库更快！</title>
		<link>http://shuai.be/archives/array-vs-database/</link>
		<comments>http://shuai.be/archives/array-vs-database/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 12:40:39 +0000</pubDate>
		<dc:creator>Jones</dc:creator>
				<category><![CDATA[PHP & Mysql]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://shuai.be/?p=1967</guid>
		<description><![CDATA[人间API研究手记之一：事实证明，PHP对数组操作比读取数据库更快，而这两者都比直接读取API数据要快！ @f0ur同学前些日子提出做好友分组，我感觉是个非常好的想法，于是乎今天小试了一下。先分析，既然要分组，那必须在本地保存好友信息，mysql数据库是必须用的了。先通过API获取到关注好友信息，把它们写入数据库，然后再从中读取。事实证明，读取API和写库这一阶段用时较长，之后的读库就是非常快的了。 那么怎样调用保存在数据库里的信息，并进行分析才能达到特定的目的呢？方法很多，今天@jones用了三种方法，并且记录了各种方法的页面执行时间。下面是结果： 比如我想实现的是从数据库中找出我关注的好友中男生的列表，女生列表，性别保密列表，同时找到我关注但未关注我的所有好友。 通过以下三种方法： 1. 从库中直接读取男，女，保密和未关注好友信息，分别赋值给不同数组；（平均执行时间0.011s, 查询数据库4次） 2. 从库中读取所有我关注的好友信息，在mysql_fetch_array()的同时，根据不同的需要，把记录值分别赋给不同数组；（平均执行时间0.0062s, 查询数据库1次） 3. 从库中读取所有我关注的好友信息，把结果集赋给一个二维数组，并循环这个数组，根据不同需要把数据键值分别赋给不同的数组。（平均执行时间0.0057s, 查询数据库1次） 以上结果说明，要提高页面打开速度，要尽量减少数据库查询次数，并且循环数组foreach比while效率高。 怎么说到最后感觉成废话了。。。但不亲身试验是不会有体会的，因为页面打开速度差几毫秒，根本感觉不出来。算是以后写程序优化速度的基础吧。 技术有限，高手轻拍~ 延伸阅读： PHP中数组按键名和键值排序函数 Include,require,include_once,require_once 谈谈PHP中单引号和双引号的区别]]></description>
			<content:encoded><![CDATA[<p><span class='wp_keywordlink'><a href="http://renjian.info/app/" title="人间API应用网站：人间.info" target="_blank">人间API</a></span>研究手记之一：事实证明，PHP对数组操作比读取数据库更快，而这两者都比直接读取API数据要快！</p>
<p>@f0ur同学前些日子提出做好友分组，我感觉是个非常好的想法，于是乎今天小试了一下。先分析，既然要分组，那必须在本地保存好友信息，mysql数据库是必须用的了。先通过API获取到关注好友信息，把它们写入数据库，然后再从中读取。事实证明，读取API和写库这一阶段用时较长，之后的读库就是非常快的了。</p>
<p>那么怎样调用保存在数据库里的信息，并进行分析才能达到特定的目的呢？方法很多，今天@jones用了三种方法，并且记录了各种方法的页面执行时间。下面是结果：<br />
<span id="more-1967"></span><br />
比如我想实现的是从数据库中找出我关注的好友中男生的列表，女生列表，性别保密列表，同时找到我关注但未关注我的所有好友。</p>
<p>通过以下三种方法：</p>
<blockquote><p>
1. 从库中直接读取男，女，保密和未关注好友信息，分别赋值给不同数组；（平均执行时间0.011s, 查询数据库4次）<br />
2. 从库中读取所有我关注的好友信息，在mysql_fetch_<span class='wp_keywordlink_affiliate'><a href="http://shuai.be/tags/array/" title="查看 array 中的全部文章" target="_blank">array</a></span>()的同时，根据不同的需要，把记录值分别赋给不同数组；（平均执行时间0.0062s, 查询数据库1次）<br />
3. 从库中读取所有我关注的好友信息，把结果集赋给一个二维数组，并循环这个数组，根据不同需要把数据键值分别赋给不同的数组。（平均执行时间0.0057s, 查询数据库1次）</p></blockquote>
<p><strong>以上结果说明，要提高页面打开速度，要尽量减少数据库查询次数，并且循环数组foreach比while效率高。</strong></p>
<p>怎么说到最后感觉成废话了。。。但不亲身试验是不会有体会的，因为页面打开速度差几毫秒，根本感觉不出来。算是以后写程序优化速度的基础吧。</p>
<p>技术有限，高手轻拍~</p>
<p><strong>延伸阅读：</strong><ol>
<li><a href='http://shuai.be/archives/php-array-sort-functions/' rel='bookmark' title='PHP中数组按键名和键值排序函数'>PHP中数组按键名和键值排序函数</a></li>
<li><a href='http://shuai.be/archives/include-require-once/' rel='bookmark' title='Include,require,include_once,require_once'>Include,require,include_once,require_once</a></li>
<li><a href='http://shuai.be/archives/php-quote-marks/' rel='bookmark' title='谈谈PHP中单引号和双引号的区别'>谈谈PHP中单引号和双引号的区别</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://shuai.be/archives/array-vs-database/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP中数组按键名和键值排序函数</title>
		<link>http://shuai.be/archives/php-array-sort-functions/</link>
		<comments>http://shuai.be/archives/php-array-sort-functions/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 18:19:42 +0000</pubDate>
		<dc:creator>Jones</dc:creator>
				<category><![CDATA[PHP & Mysql]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://shuai.be/?p=1948</guid>
		<description><![CDATA[大家知道，数组排序最常用的函数就是 sort($arr); 它的作用是按数组的键值升序排列，并且排序后的数组键名不再是原来的键名，是按新数组来重新设置的键名。 而有时我们要求更复杂的排序。如按键名排序，这里用到 ksort($arr); 函数，它会根据数组的键名排序，并维持原有的键值关系。相对应的 asort($arr); 函数，是按键值排序，且维持原有的键值关系。 同样原理，rsort(); arsort(); krsort(); 函数除了排序是按降序排列外，其它与sort(); rsort(); ksort(); 相同。 数组操作是PHP很重要的基础，希望能好好运用。 延伸阅读： 人间API研究手记之一：PHP对数组操作比读取数据库更快！ Include,require,include_once,require_once 谈谈PHP中单引号和双引号的区别]]></description>
			<content:encoded><![CDATA[<p>大家知道，数组排序最常用的函数就是 sort($arr); 它的作用是按数组的键值升序排列，并且排序后的数组键名不再是原来的键名，是按新数组来重新设置的键名。<br />
而有时我们要求更复杂的排序。如按键名排序，这里用到 ksort($arr); 函数，它会根据数组的键名排序，并维持原有的键值关系。相对应的 asort($arr); 函数，是按键值排序，且维持原有的键值关系。<br />
<span id="more-1948"></span><br />
同样原理，rsort(); arsort(); krsort(); 函数除了排序是按降序排列外，其它与sort(); rsort(); ksort(); 相同。<br />
数组操作是PHP很重要的基础，希望能好好运用。</p>
<p><strong>延伸阅读：</strong><ol>
<li><a href='http://shuai.be/archives/array-vs-database/' rel='bookmark' title='人间API研究手记之一：PHP对数组操作比读取数据库更快！'>人间API研究手记之一：PHP对数组操作比读取数据库更快！</a></li>
<li><a href='http://shuai.be/archives/include-require-once/' rel='bookmark' title='Include,require,include_once,require_once'>Include,require,include_once,require_once</a></li>
<li><a href='http://shuai.be/archives/php-quote-marks/' rel='bookmark' title='谈谈PHP中单引号和双引号的区别'>谈谈PHP中单引号和双引号的区别</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://shuai.be/archives/php-array-sort-functions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP MySQL多表联查SQL语句</title>
		<link>http://shuai.be/archives/mysql-complex-query/</link>
		<comments>http://shuai.be/archives/mysql-complex-query/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 09:55:22 +0000</pubDate>
		<dc:creator>Jones</dc:creator>
				<category><![CDATA[PHP & Mysql]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://shuai.be/?p=1475</guid>
		<description><![CDATA[也就是复合查询，例句如下 SELECT * FROM table1 n, table2 i WHERE n.itemid = i.itemid 延伸阅读： Include,require,include_once,require_once 谈谈PHP中单引号和双引号的区别 解决mysql修改密码phpmyadmin不能登录]]></description>
			<content:encoded><![CDATA[<p>也就是复合查询，例句如下</p>
<pre style="font: 10pt Consolas, Courier New;">
<font color=#0000FF>SELECT</font> * <font color=#0000FF>FROM</font> table1 n, table2 i <font color=#0000FF>WHERE</font> n.itemid = i.itemid
</pre>
<p><strong>延伸阅读：</strong><ol>
<li><a href='http://shuai.be/archives/include-require-once/' rel='bookmark' title='Include,require,include_once,require_once'>Include,require,include_once,require_once</a></li>
<li><a href='http://shuai.be/archives/php-quote-marks/' rel='bookmark' title='谈谈PHP中单引号和双引号的区别'>谈谈PHP中单引号和双引号的区别</a></li>
<li><a href='http://shuai.be/archives/mysql-pass-update/' rel='bookmark' title='解决mysql修改密码phpmyadmin不能登录'>解决mysql修改密码phpmyadmin不能登录</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://shuai.be/archives/mysql-complex-query/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>php中include require utf-8文件时顶部产生空行的解决办法</title>
		<link>http://shuai.be/archives/php-require-extra-line/</link>
		<comments>http://shuai.be/archives/php-require-extra-line/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 06:07:26 +0000</pubDate>
		<dc:creator>Jones</dc:creator>
				<category><![CDATA[PHP & Mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://shuai.be/?p=1455</guid>
		<description><![CDATA[在php中使用require函数加载utf8文件的时候会产生一个空行，这是由于在windows环境下编辑文件的时候会产生几个识别utf8的字符，这些字符称为Unicode签名（BOM）。 特别是用记事本将网页文件由ANSI另存为UTF-8时易出现！ 解决办法： 1. 可以通过在Dreamweaver中按Ctrl+J，在标题与编码中去除此选项； 2. 用EditPlus将文件另存为UTF-8（无BOM）文件。 延伸阅读： require() vs require_once() &#038; include() vs include_once() Include,require,include_once,require_once 谈谈PHP中单引号和双引号的区别]]></description>
			<content:encoded><![CDATA[<p>在<span class='wp_keywordlink_affiliate'><a href="http://shuai.be/tags/php/" title="查看 php 中的全部文章" target="_blank">php</a></span>中使用require函数加载utf8文件的时候会产生一个空行，这是由于在windows环境下编辑文件的时候会产生几个识别utf8的字符，这些字符称为Unicode签名（BOM）。<br />
特别是用记事本将网页文件由ANSI另存为UTF-8时易出现！</p>
<p>解决办法：<br />
1. 可以通过在Dreamweaver中按Ctrl+J，在标题与编码中去除此选项；<br />
2. 用EditPlus将文件另存为UTF-8（无BOM）文件。</p>
<p><strong>延伸阅读：</strong><ol>
<li><a href='http://shuai.be/archives/require-include-once/' rel='bookmark' title='require() vs require_once() &amp; include() vs include_once()'>require() vs require_once() &#038; include() vs include_once()</a></li>
<li><a href='http://shuai.be/archives/include-require-once/' rel='bookmark' title='Include,require,include_once,require_once'>Include,require,include_once,require_once</a></li>
<li><a href='http://shuai.be/archives/php-quote-marks/' rel='bookmark' title='谈谈PHP中单引号和双引号的区别'>谈谈PHP中单引号和双引号的区别</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://shuai.be/archives/php-require-extra-line/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>解决mysql修改密码phpmyadmin不能登录</title>
		<link>http://shuai.be/archives/mysql-pass-update/</link>
		<comments>http://shuai.be/archives/mysql-pass-update/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 15:47:01 +0000</pubDate>
		<dc:creator>Jones</dc:creator>
				<category><![CDATA[PHP & Mysql]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[phpmyadmin]]></category>

		<guid isPermaLink="false">http://shuai.be/?p=1196</guid>
		<description><![CDATA[在phpmyadmin目录中找到config.inc.php文件，修改如下位置即可 $cfg['Servers'][$i]['user'] = 'user'; $cfg['Servers'][$i]['password'] = 'password'; 延伸阅读： 关于NULL与NOT NULL PHP MySQL多表联查SQL语句]]></description>
			<content:encoded><![CDATA[<p>在<span class='wp_keywordlink_affiliate'><a href="http://shuai.be/tags/phpmyadmin/" title="查看 phpmyadmin 中的全部文章" target="_blank">phpmyadmin</a></span>目录中找到config.inc.php文件，修改如下位置即可</p>
<pre style="font: 10pt Consolas, Courier New;">
$cfg[<font color=#FF00FF>'Servers'</font>][$i][<font color=#FF00FF>'user'</font>] = <font color=#FF00FF>'user'</font>;
$cfg[<font color=#FF00FF>'Servers'</font>][$i][<font color=#FF00FF>'password'</font>] = <font color=#FF00FF>'password'</font>;
</pre>
<p><strong>延伸阅读：</strong><ol>
<li><a href='http://shuai.be/archives/null-and-not-null/' rel='bookmark' title='关于NULL与NOT NULL'>关于NULL与NOT NULL</a></li>
<li><a href='http://shuai.be/archives/mysql-complex-query/' rel='bookmark' title='PHP MySQL多表联查SQL语句'>PHP MySQL多表联查SQL语句</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://shuai.be/archives/mysql-pass-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP三元运算符的用法</title>
		<link>http://shuai.be/archives/php-simple-condition/</link>
		<comments>http://shuai.be/archives/php-simple-condition/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 12:59:01 +0000</pubDate>
		<dc:creator>Jones</dc:creator>
				<category><![CDATA[PHP & Mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://shuai.be/?p=1075</guid>
		<description><![CDATA[在某些情况下，这样用更方便，如： $var = $bool ? $val_1 : $val_2; //如果$bool = true，则$var = $val_1；如果$bool ＝ false，则$var = $val_2. 用起来很是简便。 延伸阅读： Include,require,include_once,require_once 谈谈PHP中单引号和双引号的区别 php中include require utf-8文件时顶部产生空行的解决办法]]></description>
			<content:encoded><![CDATA[<p>在某些情况下，这样用更方便，如：</p>
<pre style="font: 10pt Consolas, Courier New;">
$<font color=#0000FF>var</font> = $<font color=#0000FF>bool</font> ? $val_1 : $val_2;
<font color=#008000>//如果$bool = true，则$var = $val_1；如果$bool ＝ false，则$var = $val_2.</font>
</pre>
<p>用起来很是简便。</p>
<p><strong>延伸阅读：</strong><ol>
<li><a href='http://shuai.be/archives/include-require-once/' rel='bookmark' title='Include,require,include_once,require_once'>Include,require,include_once,require_once</a></li>
<li><a href='http://shuai.be/archives/php-quote-marks/' rel='bookmark' title='谈谈PHP中单引号和双引号的区别'>谈谈PHP中单引号和双引号的区别</a></li>
<li><a href='http://shuai.be/archives/php-require-extra-line/' rel='bookmark' title='php中include require utf-8文件时顶部产生空行的解决办法'>php中include require utf-8文件时顶部产生空行的解决办法</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://shuai.be/archives/php-simple-condition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>谈谈PHP中单引号和双引号的区别</title>
		<link>http://shuai.be/archives/php-quote-marks/</link>
		<comments>http://shuai.be/archives/php-quote-marks/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 12:17:24 +0000</pubDate>
		<dc:creator>Jones</dc:creator>
				<category><![CDATA[PHP & Mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://shuai.be/?p=1074</guid>
		<description><![CDATA[在程序语言中，无论是单引号还是双引号，都有很重要的作用，在PHP语言中也一样。 跟ASP相比，PHP的引号更好用，在ASP中，要把数据代入变量就必须用双引号包含起来，而且里面要用到引号的情况下只能用单引号，不能用双引号，如果用了双引号就会把其当作前一个引号的结束符。但在PHP中就没有这个限制了。代值进去变量，单引号和双引号都可以使用， 但要成对使用。 在PHP中，如果只是用于没有包含变量的文本型数据，单引号和双引号是没有什么区别的。但如果要使用变量，单引号和双引号就有区别了。在PHP中，双引号里可以直接代入变量，而无需转定义或者其他符号，如：$b = “cat”;$a = “This is a $b”;//显示This is a cat单引号则不行，如果$a = ‘This is a $b’，则显示为：This is a $b。 在运行效率上单引号和双引号也是有区别的，一般来说单引号的运行速度会比较快，双引号会比较慢，原因在于双引号要先查找语句中是否有变量，而单引号则不用，因此，如果语句中没有代入变量尽量采用单引号。这是写程序一种习惯，时刻想着提高程序的效率。 如果在语句中要转定义操作，那么就一定要用双引号了。比如，转定义单引号时，写成这样的话：$a = ‘He\’s name is Tom.’ ，程序会把He\’s name is Tom.原封不动的显示出来，如果这样写：$a = “He\’s name is Tom.”，程序就会显示：He’s name is Tom. 单引号是sql语句的绊脚石，在sql语句中的文本型数据都要用单引号来包含，因此数据中如果出现单引号，数据库会认为数据结束，那么后面的数据就会被认为是sql语句的其它组成部分，在数据库查询时当然会报错，所以写进sql语句的文本型数据一定要用addslashes()函数转定义单引号，读取数据时再用stripslashes()转回来。 从PHP的单引号和双引号可以看出，PHP语言比ASP语言跟有生命力，因为它很灵活，而且想的很周到，从单引号和双引号的这些点滴就可以看出。 延伸阅读： Include,require,include_once,require_once PHP三元运算符的用法 php中include require utf-8文件时顶部产生空行的解决办法]]></description>
			<content:encoded><![CDATA[<p>在程序语言中，无论是单引号还是双引号，都有很重要的作用，在PHP语言中也一样。 跟ASP相比，PHP的引号更好用，在ASP中，要把数据代入变量就必须用双引号包含起来，而且里面要用到引号的情况下只能用单引号，不能用双引号，如果用了双引号就会把其当作前一个引号的结束符。但在PHP中就没有这个限制了。代值进去变量，单引号和双引号都可以使用， 但要成对使用。<br />
<span id="more-1074"></span><br />
在PHP中，如果只是用于没有包含变量的文本型数据，单引号和双引号是没有什么区别的。但如果要使用变量，单引号和双引号就有区别了。在PHP中，双引号里可以直接代入变量，而无需转定义或者其他符号，如：$b = “cat”;$a = “This is a $b”;//显示This is a cat单引号则不行，如果$a = ‘This is a $b’，则显示为：This is a $b。</p>
<p>在运行效率上单引号和双引号也是有区别的，一般来说单引号的运行速度会比较快，双引号会比较慢，原因在于双引号要先查找语句中是否有变量，而单引号则不用，因此，如果语句中没有代入变量尽量采用单引号。这是写程序一种习惯，时刻想着提高程序的效率。</p>
<p>如果在语句中要转定义操作，那么就一定要用双引号了。比如，转定义单引号时，写成这样的话：$a = ‘He\’s name is Tom.’ ，程序会把He\’s name is Tom.原封不动的显示出来，如果这样写：$a = “He\’s name is Tom.”，程序就会显示：He’s name is Tom.</p>
<p>单引号是sql语句的绊脚石，在sql语句中的文本型数据都要用单引号来包含，因此数据中如果出现单引号，数据库会认为数据结束，那么后面的数据就会被认为是sql语句的其它组成部分，在数据库查询时当然会报错，所以写进sql语句的文本型数据一定要用addslashes()函数转定义单引号，读取数据时再用stripslashes()转回来。</p>
<p>从PHP的单引号和双引号可以看出，PHP语言比ASP语言跟有生命力，因为它很灵活，而且想的很周到，从单引号和双引号的这些点滴就可以看出。</p>
<p><strong>延伸阅读：</strong><ol>
<li><a href='http://shuai.be/archives/include-require-once/' rel='bookmark' title='Include,require,include_once,require_once'>Include,require,include_once,require_once</a></li>
<li><a href='http://shuai.be/archives/php-simple-condition/' rel='bookmark' title='PHP三元运算符的用法'>PHP三元运算符的用法</a></li>
<li><a href='http://shuai.be/archives/php-require-extra-line/' rel='bookmark' title='php中include require utf-8文件时顶部产生空行的解决办法'>php中include require utf-8文件时顶部产生空行的解决办法</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://shuai.be/archives/php-quote-marks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Include,require,include_once,require_once</title>
		<link>http://shuai.be/archives/include-require-once/</link>
		<comments>http://shuai.be/archives/include-require-once/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 07:25:24 +0000</pubDate>
		<dc:creator>Jones</dc:creator>
				<category><![CDATA[PHP & Mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://shuai.be/?p=1063</guid>
		<description><![CDATA[这几个的区别呢 经常会听到有人讨论 连一些PHPER面试都会出这个题目 我浅显的说一下我的意见 先看手册怎么说的： include&#38;require include()语句包含并运行指定文件。 以下文档也适用于require()。这两种结构除了在如何处理失败之外完全一样。include()产生一个警告而require()则导致一个致命错误。换句话说，如果想在遇到丢失文件时停止处理页面就用require()。include()就不是这样，脚本会继续运行。同时也要确认设置了合适的include_path。注意在 PHP 4.3.5 之前，包含文件中的语法错误不会导致程序停止，但从此版本之后会。 include_once Theinclude_once()语句在脚本执行期间包含并运行指定文件。此行为和include()语句类似，唯一区别是如果该文件中的代码已经被包含了，则不会再次包含。如同此语句名字暗示的那样，只会包含一次。 include_once()应该用于在脚本执行期间同一个文件有可能被包含超过一次的情况下，想确保它只被包含一次以避免函数重定义，变量重新赋值等问题。 require_once require_once()语句在脚本执行期间包含并运行指定文件。此行为和require()语句类似，唯一区别是如果该文件中的代码已经被包含了，则不会再次包含。有关此语句怎样工作参见require()的文档。 require_once()应该用于在脚本执行期间同一个文件有可能被包含超过一次的情况下，想确保它只被包含一次以避免函数重定义，变量重新赋值等问题。 个人使用经验： 1.路径问题。 特别是 嵌套包含的时候，一定的注意包含文件的路径。 比如 A文件包含了B文件，B文件包含了C文件，A,B,C文件都不在同一个文件夹下，这个时候往往很容易出错误。 解决方案：定义一个基路径sitebase 2.效率问题 include_once,require_once,与include,require比较，效率要低一点，因为他们至少得先判断一下这个文件是否存在。 延伸阅读： require() vs require_once() &#038; include() vs include_once() php中include require utf-8文件时顶部产生空行的解决办法 PHP三元运算符的用法]]></description>
			<content:encoded><![CDATA[<p>这几个的区别呢<br />
 经常会听到有人讨论</p>
<p>连一些PHPER面试都会出这个题目</p>
<p>我浅显的说一下我的意见</p>
<p><span id="more-1063"></span></p>
<p>先看手册怎么说的：</p>
<div id="pageHeaders">
<h1 class="masterheader"><span style="font-size: 16px;">include&amp;require<br />
</span></h1>
</div>
<div id="pageText">
<p><a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.include.html">include()</a>语句包含并运行指定文件。</p>
<p>以下文档也适用于<a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.require.html">require()</a>。这两种结构除了在如何处理失败之外完全一样。<a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.include.html">include()</a>产生一个<a title="E_WARNING" href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/phpdevel-errors.html#internal.e-warning">警告</a>而<a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.require.html">require()</a>则导致一个<a title="E_ERROR" href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/phpdevel-errors.html#internal.e-error">致命错误</a>。换句话说，如果想在遇到丢失文件时停止处理页面就用<a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.require.html">require()</a>。<a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.include.html">include()</a>就不是这样，脚本会继续运行。同时也要确认设置了合适的<a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/ini.core.html#ini.include-path">include_path</a>。注意在 <a onclick="tagshow(event, 'PHP');" href="javascript:;" target="_self">PHP</a> 4.3.5 之前，包含文件中的语法错误不会导致程序停止，但从此版本之后会。</p>
</div>
<div id="pageHeaders">
<h1 class="masterheader"><span style="font-size: 16px;">include_once</span></h1>
</div>
<div id="pageText">
<p>Theinclude_once()语句在脚本执行期间包含并运行指定文件。此行为和<a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.include.html">include()</a>语句类似，唯一区别是如果该文件中的<a onclick="tagshow(event, '%B4%FA%C2%EB');" href="javascript:;" target="_self">代码</a>已经被包含了，则不会再次包含。如同此语句名字暗示的那样，只会包含一次。</p>
<p><a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.include-once.html">include_once()</a>应该用于在脚本执行期间同一个文件有可能被包含超过一次的情况下，想确保它只被包含一次以避免函数重定义，变量重新赋值等问题。</p>
</div>
<div id="pageHeaders">
<h1 class="masterheader"><span style="font-size: 16px;">require_once</span></h1>
</div>
<div id="pageText">
<p><a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.require-once.html">require_once()</a>语句在脚本执行期间包含并运行指定文件。此行为和<a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.require.html">require()</a>语句类似，唯一区别是如果该文件中的代码已经被包含了，则不会再次包含。有关此语句怎样<a onclick="tagshow(event, '%B9%A4%D7%F7');" href="javascript:;" target="_self">工作</a>参见<a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.require.html">require()</a>的文档。</p>
<p><a href="mk:@MSITStore:F:\Bank\handbook\php\php_manual_zh.chm::/function.require-once.html">require_once()</a>应该用于在脚本执行期间同一个文件有可能被包含超过一次的情况下，想确保它只被包含一次以避免函数重定义，变量重新赋值等问题。</p>
</div>
<p>个人使用经验：</p>
<p>1.路径问题。</p>
<p>
 特别是 嵌套包含的时候，一定的注意包含文件的路径。</p>
<p>
 比如 A文件包含了B文件，B文件包含了C文件，A,B,C文件都不在同一个文件夹下，这个时候往往很容易出错误。</p>
<p>
 解决方案：定义一个基路径sitebase</p>
<p>2.效率问题</p>
<p>
include_once,require_once,与include,require比较，效率要低一点，因为他们至少得先判断一下这个文件是否存在。</p>
<p><strong>延伸阅读：</strong><ol>
<li><a href='http://shuai.be/archives/require-include-once/' rel='bookmark' title='require() vs require_once() &amp; include() vs include_once()'>require() vs require_once() &#038; include() vs include_once()</a></li>
<li><a href='http://shuai.be/archives/php-require-extra-line/' rel='bookmark' title='php中include require utf-8文件时顶部产生空行的解决办法'>php中include require utf-8文件时顶部产生空行的解决办法</a></li>
<li><a href='http://shuai.be/archives/php-simple-condition/' rel='bookmark' title='PHP三元运算符的用法'>PHP三元运算符的用法</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://shuai.be/archives/include-require-once/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

