<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Enjoy]]></title> 
<link>http://www.9enjoy.com/index.php</link> 
<description><![CDATA[分享、学习、提高]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Enjoy]]></copyright>
<item>
<link>http://www.9enjoy.com/smarty-some-function/</link>
<title><![CDATA[Smarty一些不常用的功能记录]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Sun, 20 Jan 2013 13:52:49 +0000</pubDate> 
<guid>http://www.9enjoy.com/smarty-some-function/</guid> 
<description>
<![CDATA[ 
	<strong>注释</strong><br/><br/>&#123;* 这是一个单行Smarty注释 来自于9enjoy.com，网页源代码里看不见*&#125;<br/><!-- HTML注释将发送到浏览器 来自于9enjoy.com，网页源代码里看得见 --><br/><br/>&#123;* 这是一个多行<br/>&nbsp;&nbsp; Smarty注释<br/>&nbsp;&nbsp; 并不发送到浏览器<br/>*&#125;<br/><br/><br/>&nbsp;&nbsp;&nbsp;&nbsp; 模板注释由星号包围，继而由分隔符包围，型如：&#123;* 这是一个注释 *&#125;。Smarty注释不会在最终模板的输出中显示，这点和<!-- HTML comments -->不同。前者对于在模板中插入内部注释有用，因为没有人能看到。;-)<br/><br/><a href="http://www.itlearner.com/code/smarty_cn/language.basic.syntax.html" target="_blank">http://www.itlearner.com/code/smarty_cn/language.basic.syntax.html</a><br/><br/><strong>截断truncate</strong><br/><br/><?php<br/>$smarty->assign('hxtitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');<br/>?><br/><br/>&nbsp;&nbsp;&nbsp;&nbsp; 模板为：<br/><br/>&#123;$hxtitle&#125;<br/>&#123;$hxtitle&#124;truncate&#125;<br/>&#123;$hxtitle&#124;truncate:30&#125;<br/>&#123;$hxtitle&#124;truncate:30:""&#125;<br/>&#123;$hxtitle&#124;truncate:30:"---"&#125;<br/>&#123;$hxtitle&#124;truncate:30:"":true&#125;<br/>&#123;$hxtitle&#124;truncate:30:"...":true&#125;<br/>&#123;$hxtitle&#124;truncate:30:'..':true:true&#125;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp; 输出为：<br/><br/>Two Sisters Reunite after Eighteen Years at Checkout Counter.<br/>Two Sisters Reunite after Eighteen Years at Checkout Counter.<br/>Two Sisters Reunite after...<br/>Two Sisters Reunite after<br/>Two Sisters Reunite after---<br/>Two Sisters Reunite after Eigh<br/>Two Sisters Reunite after E...<br/>Two Sisters Re..ckout Counter.<br/><br/>可以不用在PHP里截取了：<a href="http://www.itlearner.com/code/smarty_cn/language.modifier.truncate.html" target="_blank">http://www.itlearner.com/code/smarty_cn/language.modifier.truncate.html</a><br/>Tags - <a href="http://www.9enjoy.com/tags/smarty/" rel="tag">smarty</a> , <a href="http://www.9enjoy.com/tags/%25E6%25A8%25A1%25E6%259D%25BF/" rel="tag">模板</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/php-messagepack/</link>
<title><![CDATA[PHP试用MessagePack]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Sat, 15 Sep 2012 07:58:59 +0000</pubDate> 
<guid>http://www.9enjoy.com/php-messagepack/</guid> 
<description>
<![CDATA[ 
	It&#039;s like JSON. but fast and small. <br/><br/>这句吸引了我，去瞧了下。<br/><br/>官网：<a href="http://msgpack.org" target="_blank">http://msgpack.org</a><br/><br/>官方的安装方法忽悠人，msgpack目录下根本没php目录...只看到csharp,erlang,go,java,ruby等目录。<div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>git clone <a href="https://github.com/msgpack/msgpack.git" target="_blank">https://github.com/msgpack/msgpack.git</a><br/>cd msgpack/php<br/>phpize<br/>./configure &amp;&amp; make &amp;&amp; make install</div></div><br/><br/>还是在PHP官网扩展找到了：<a href="http://pecl.php.net/package/msgpack" target="_blank">http://pecl.php.net/package/msgpack</a><br/>最后更新时间：2012-09-14，昨天的版本。<br/>附安装过程：<div class="code">wget http://pecl.php.net/get/msgpack-0.5.2.tgz<br/>tar zxf msgpack-0.5.2.tgz <br/>cd msgpack-0.5.2<br/>/usr/local/hx/php/bin/phpize <br/>./configure --with-php-config=/usr/local/hx/php/bin/php-config <br/>make &amp;&amp; make install</div><br/>然后把msgpack.so加到php.ini里，重启php，完成安装。<br/><br/>开始测试：<br/>$data = array(0=&gt;&#039;abcdefghijklmnopqrstuvwxyz&#039;,1=&gt;&#039;厦门&#039;,&#039;abc&#039;=&gt;&#039;1234567890&#039;);<br/><br/>分别对其msgpack_pack，json_encode，serialize，长度为：50,62,87<br/>然后分别执行10000次，耗时：9.95 毫秒，17.45 毫秒，8.85 毫秒<br/>解开执行10000次，耗时：14.76 毫秒，23.93 毫秒，14.61 毫秒<br/><br/>msgpack的性能至少超过json50%，虽然和serialize其实速度差不多，但serialize占用空间明显比较多。<br/><br/>另外，GBK的程序方便了，中文也可以msgpack_pack，用json的话还要批量转换成utf-8之后才能json_encode。<br/>Tags - <a href="http://www.9enjoy.com/tags/php/" rel="tag">php</a> , <a href="http://www.9enjoy.com/tags/json/" rel="tag">json</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/firefox-css-img-referer/</link>
<title><![CDATA[Firefox下CSS里调用的图片显示不出来？]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Mon, 16 Jul 2012 12:21:33 +0000</pubDate> 
<guid>http://www.9enjoy.com/firefox-css-img-referer/</guid> 
<description>
<![CDATA[ 
	近期公司网站上部分图片启用了CDN，并且加上了防盗链，一切访问正常。但某同事在Firefox下浏览时发现，图片显示不了。<br/>查询后，发现同在CDN上的图片，部分图片访问不了，显示403 Forbidden，但有部分又是可以正常访问的。清缓存，依旧。<br/>再检查，发现是css里调的图片显示不出来，而页面上直接用&lt;img src=&quot;&quot;&gt;方式调用的图片都可以正常显示。<br/>其它浏览器,IE6~9，Chrome均正常，怀疑是Firefox版本问题，看了两个FF版本，都有此问题。<br/>再检查，发现在Fifefox下此图片的referer是调用它的CSS，而Chrome下此图片的referer是网页地址...<br/><br/>假设首页http://www.itlearner.com/，图片域名是img.9enjoy.com。<br/>首页的css是img.9enjoy.com/hx.css，hx.css中有调用了一张背景图片叫enjoy.jpg (绝对路径是：img.9enjoy.com/img/enjoy.jpg)<br/>此时用户打开首页，这张enjoy.jpg图片在请求时：<br/>FireFox下referer是：http://img.9enjoy.com/hx.css<br/>chrome下referer是：http://www.itlearner.com/<br/><br/>这样，如果img.9enjoy.com开启了防盗链，并且只加了itlearner.com，但没有加上自身域名img.9enjoy.com，则在Firefox下属于盗链，不于显示。。。<br/><br/>问题发现了，通知CDN加上图片域名本身，问题解决。<br/><br/>PS：只有Firefox在请求CSS中的图片是发出的Referer是css文件的URL，其它浏览器(测试过IE,chrome）的Referer都是页面URL。<br/>Tags - <a href="http://www.9enjoy.com/tags/css/" rel="tag">css</a> , <a href="http://www.9enjoy.com/tags/firefox/" rel="tag">firefox</a> , <a href="http://www.9enjoy.com/tags/referer/" rel="tag">referer</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/php-file-exists/</link>
<title><![CDATA[判断文件存在用is_file还是file_exists？]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Thu, 28 Jun 2012 02:14:28 +0000</pubDate> 
<guid>http://www.9enjoy.com/php-file-exists/</guid> 
<description>
<![CDATA[ 
	判断文件存在用is_file还是file_exists？<br/><br/>在写程序时发现在判断文件是否存在时，有两种写法，有的人用了is_file，有的人用了file_exists，用哪个更好或者说更合适呢？<br/><br/>看了这篇<a href="http://www.itlearner.com/article/4917" target="_blank">PHP中file_exists与is_file,is_dir的区别</a>的说法基本明白，PHP的 file_exists = is_dir + is_file。<br/><br/>写程序验证一下：<br/><br/>分别执行1000次，记录所需时间。<br/><br/>文件存在(当前目录)<br/>is_file:0.4570ms<br/>file_exists:2.0640ms<br/><br/>文件存在(绝对路径3层/www/hx/a/)<br/>is_file:0.4909ms<br/>file_exists:3.3500ms<br/><br/>文件存在(绝对路径5层/www/hx/a/b/c/)<br/>is_file:0.4961ms<br/>file_exists:4.2100ms<br/><br/>文件不存在(当前目录)<br/>is_file:2.0170ms<br/>file_exists:1.9848ms<br/><br/>文件不存在(绝对路径5层/www/hx/a/b/c/)<br/>is_file:4.1909ms<br/>file_exists:4.1502ms<br/><br/>目录存在<br/>file_exists:2.9271ms<br/>is_dir:0.4601ms<br/>目录不存在<br/>file_exists:2.9719ms<br/>is_dir:2.9359ms<br/><br/><br/><br/>is_file($file)<br/>file_exists($file)<br/>当$file是目录时，is_file返回false，file_exists返回true<br/><br/><br/>文件存在的情况下，is_file比file_exists要快得多；<br/>要检测文件所在的目录越深，速度差越多，但至少快4倍。<br/><br/>文件不存在的情况下，is_file比file_exists要慢一点点，但可以忽略不计。<br/><br/>目录存在的情况下，is_dir比file_exists要快得多；<br/>目录不存在的情况下，is_dir比file_exists要慢一点点，但可以忽略不计。<br/><br/>结论:<br/>如果要判断文件是否存在，用函数 is_file()，<br/>如果要判断目录是否存在，用函数 is_dir(),<br/>好像没地方需要用file_exists了，不确定传入的参数是文件还是目录的时候用？<br/><br/>附测试程序：<br/><div class="code"><br/>function runtime($t1)&#123;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;return number_format((microtime(true) - $t1)*1000, 4).&#039;ms&#039;;<br/>&#125;<br/>$times = 1000;<br/><br/>$t1 = microtime(true);<br/>for($i=0;$i&lt;$times;$i++)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;is_file(&#039;/www/hx/www.9enjoy.com/config.php&#039;);<br/>&#125;<br/><br/>echo &#039;&lt;br&gt;is_file:&#039;.runtime($t1);<br/><br/>$t2 = microtime(true);&nbsp;&nbsp;<br/>for($i=0;$i&lt;$times;$i++)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;file_exists(&#039;/www/hx/www.9enjoy.com/config.php&#039;);<br/>&#125;<br/>echo &#039;&lt;br&gt;file_exists:&#039;.runtime($t2);&nbsp;&nbsp; <br/><br/>/*<br/>$t3 = microtime(true);&nbsp;&nbsp;<br/>for($i=0;$i&lt;$times;$i++)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;is_dir(&#039;/www/hx/www.9enjoy.com/&#039;);<br/>&#125;<br/>echo &#039;&lt;br&gt;is_dir:&#039;.runtime($t3);&nbsp;&nbsp; <br/>*/<br/></div><br/>Tags - <a href="http://www.9enjoy.com/tags/php/" rel="tag">php</a> , <a href="http://www.9enjoy.com/tags/%25E6%2596%2587%25E4%25BB%25B6/" rel="tag">文件</a> , <a href="http://www.9enjoy.com/tags/%25E6%2595%2588%25E7%258E%2587/" rel="tag">效率</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/mysql-profile/</link>
<title><![CDATA[MYSQL的profile使用]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Tue, 24 Apr 2012 03:08:32 +0000</pubDate> 
<guid>http://www.9enjoy.com/mysql-profile/</guid> 
<description>
<![CDATA[ 
	MYSQL的profiling功能要在Mysql版本5.0.37以上才能使用。<br/><br/>开启profiling:<br/>set profiling=1;<br/><br/>查看是否设置生效：<br/>select @@profiling;<br/>默认是0，设置成功是1<br/><br/>运行SQL语句：<br/>mysql&gt; select * FROM hx_line WHERE id = &#039;1455023&#039;;<br/><br/>查看profiles<br/>mysql&gt; show profiles;<br/>+----------+------------+---------------------------------------------+<br/>&#124; Query_ID &#124; Duration&nbsp;&nbsp; &#124; Query&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124;<br/>+----------+------------+---------------------------------------------+<br/>&#124;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 &#124; 0.00036150 &#124; select * FROM hx_line WHERE id = &#039;1455023&#039; &#124;<br/>+----------+------------+---------------------------------------------+<br/><br/>查看具体某条的profile<br/><br/>mysql&gt; show profile FOR QUERY 1;<br/>+--------------------------------+----------+<br/>&#124; Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; Duration &#124;<br/>+--------------------------------+----------+<br/>&#124; starting&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000013 &#124;<br/>&#124; Waiting for query cache lock&nbsp;&nbsp; &#124; 0.000014 &#124;<br/>&#124; checking query cache for query &#124; 0.000038 &#124;<br/>&#124; checking permissions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000006 &#124;<br/>&#124; Opening tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000013 &#124;<br/>&#124; System lock&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000009 &#124;<br/>&#124; Waiting for query cache lock&nbsp;&nbsp; &#124; 0.000024 &#124;<br/>&#124; init&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000060 &#124;<br/>&#124; optimizing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000014 &#124;<br/>&#124; statistics&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000046 &#124;<br/>&#124; preparing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000017 &#124;<br/>&#124; executing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>&#124; Sending data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000081 &#124;<br/>&#124; end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000005 &#124;<br/>&#124; query end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>&#124; closing tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000008 &#124;<br/>&#124; freeing items&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000009 &#124;<br/>&#124; Waiting for query cache lock&nbsp;&nbsp; &#124; 0.000003 &#124;<br/>&#124; freeing items&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000013 &#124;<br/>&#124; Waiting for query cache lock&nbsp;&nbsp; &#124; 0.000003 &#124;<br/>&#124; freeing items&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000003 &#124;<br/>&#124; storing result in query cache&nbsp;&nbsp;&#124; 0.000005 &#124;<br/>&#124; logging slow query&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000003 &#124;<br/>&#124; cleaning up&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>+--------------------------------+----------+<br/>24 rows<br/><br/>我们看到了一个简单的查询，MYSQL内部做了24次操作。<br/>另外，看到了一堆query cache的操作，试着把query_cache_size=0，把query_cache关闭，再次测试：<br/><br/><br/>mysql&gt; show profile FOR QUERY 1;<br/>+----------------------+----------+<br/>&#124; Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; Duration &#124;<br/>+----------------------+----------+<br/>&#124; starting&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000040 &#124;<br/>&#124; checking permissions &#124; 0.000007 &#124;<br/>&#124; Opening tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000015 &#124;<br/>&#124; System lock&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000010 &#124;<br/>&#124; init&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000061 &#124;<br/>&#124; optimizing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000013 &#124;<br/>&#124; statistics&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000059 &#124;<br/>&#124; preparing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000018 &#124;<br/>&#124; executing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>&#124; Sending data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000092 &#124;<br/>&#124; end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000006 &#124;<br/>&#124; query end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>&#124; closing tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000008 &#124;<br/>&#124; freeing items&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000020 &#124;<br/>&#124; logging slow query&nbsp;&nbsp; &#124; 0.000003 &#124;<br/>&#124; cleaning up&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>+----------------------+----------+<br/>16 rows in set (0.00 sec)<br/><br/>当开启了query_cache的情况下，需要多操作6次，在这个示例里面多化了0.000087s。<br/><br/><strong>查询这条语句对CPU的使用情况：</strong><br/>mysql&gt; show profile cpu FOR QUERY 1;<br/>+----------------------+----------+----------+------------+<br/>&#124; Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; Duration &#124; CPU_user &#124; CPU_system &#124;<br/>+----------------------+----------+----------+------------+<br/>&#124; starting&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000037 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; checking permissions &#124; 0.000009 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; Opening tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000014 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; System lock&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000009 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; init&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000059 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; optimizing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000009 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; statistics&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000044 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; preparing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000015 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; executing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; Sending data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000081 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000006 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; query end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; closing tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000008 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; freeing items&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000021 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; logging slow query&nbsp;&nbsp; &#124; 0.000004 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; cleaning up&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>+----------------------+----------+----------+------------+<br/><br/><strong>show profile额外一些命令：</strong><br/>* ALL - displays all information<br/>* BLOCK IO - displays counts for block input and output Operations<br/>* CONTEXT SWITCHES - displays counts for voluntary and involuntary context switches<br/>* ipC - displays counts for messages sent and received<br/>* MEMORY - is not currently implemented<br/>* PAGE FAULTS - displays counts for major and minor page faults<br/>* SOURCE - displays the names of functions from the source code, together with the name and line number of the file in which the function occurs<br/>* SWAPS - displays swap counts<br/>Tags - <a href="http://www.9enjoy.com/tags/mysql/" rel="tag">mysql</a> , <a href="http://www.9enjoy.com/tags/%25E6%2580%25A7%25E8%2583%25BD/" rel="tag">性能</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/pragma-no-cache-session/</link>
<title><![CDATA[Pragma:no-cache哪里来的？]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Sat, 11 Feb 2012 14:45:42 +0000</pubDate> 
<guid>http://www.9enjoy.com/pragma-no-cache-session/</guid> 
<description>
<![CDATA[ 
	今天给同事分享了一下前端性能优化，在介绍了php文件缓存的方法后，发现一个AJAX请求的文件，在请求头中始终有一个：Pragma:no-cache，导致这个文件不能被浏览器缓存。接着发现这个站几乎所有动态页面都有这个参数Pragma:no-cache。<br/><br/>开始怀疑是不是设置了Cache-control:no-cache导致的，但查遍程序没发现。怀疑服务器的配置，没什么异常的。<br/>最后，同事定位到了页面开始的session_start()身上。。。<br/><br/>问题果然出现在它session身上！<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">session.cache_limiter string <br/>session.cache_limiter 指定会话页面所使用的缓冲控制方法（none/nocache/private/private_no_expire/public）。默认为 nocache。参见 session_cache_limiter()。 </div></div><div class="quote"><div class="quote-title">引用</div><div class="quote-content">string session_cache_limiter ( [string cache_limiter] )<br/><br/>session_cache_limiter() returns the name of the current cache limiter. If cache_limiter is specified, the name of the current cache limiter is changed to the new value. <br/><br/>The cache limiter defines which cache control HTTP headers are sent to the client. These headers determine the rules by which the page content may be cached by the client and intermediate proxies. Setting the cache limiter to nocache disallows any client/proxy caching. A value of public permits caching by proxies and the client, whereas private disallows caching by proxies and permits the client to cache the contents. <br/><br/>In private mode, the Expire header sent to the client may cause confusion for some browsers, including Mozilla. You can avoid this problem by using private_no_expire mode. The expire header is never sent to the client in this mode. <br/><br/>The cache limiter is reset to the default value stored in session.cache_limiter at request startup time. Thus, you need to call session_cache_limiter() for every request (and before session_start() is called). </div></div><br/><br/>当启用了session后，session.cache_limiter就被默认设置为nocache，所以就在http头里发送no-cache信息，导致页面不会被缓存。<br/>当然一般需要缓存的文件是不需要session的，因此去掉头部的session_start()即可。<br/>如果实在需要在启用session后还需要把这个页面缓存，则需要在session_start之前设置下session_cache_limiter(&#039;public&#039;)。<br/><br/><br/><br/>Tags - <a href="http://www.9enjoy.com/tags/%25E7%25BC%2593%25E5%25AD%2598/" rel="tag">缓存</a> , <a href="http://www.9enjoy.com/tags/session/" rel="tag">session</a> , <a href="http://www.9enjoy.com/tags/cache/" rel="tag">cache</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/json_encode_zhongwen/</link>
<title><![CDATA[json_encode后的中文不编码成unicode]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Wed, 01 Feb 2012 05:53:48 +0000</pubDate> 
<guid>http://www.9enjoy.com/json_encode_zhongwen/</guid> 
<description>
<![CDATA[ 
	当使用php自带的json_encode对数据进行编码时，中文都会变成unicode，导致不可读。如：对字符串”厦门“进行json_encode后，输出的是&quot;&#92;u53a6&#92;u95e8&quot;。<br/><br/>查询了一下，有两种方法：<br/>1.将&quot;&#92;u53a6&#92;u95e8&quot;还原成“厦门”，使用如下的代码：<div class="code">$str= preg_replace(&quot;#&#92;&#92;&#92;u(&#91;0-9a-f&#93;+)#ie&quot;, &quot;iconv(&#039;UCS-2&#039;, &#039;UTF-8&#039;, pack(&#039;H4&#039;, &#039;&#92;&#92;1&#039;))&quot;, $str);</div><br/>2.先将中文字段urlencode，json_encode后，再用urldecode，也可以显示中文。<div class="code">$code = urldecode(json_encode(urlencode(&quot;厦门&quot;)));</div><br/>PHP5.4版本，已经给Json新增了一个选项: JSON_UNESCAPED_UNICODE。加上这个选项后，就不会自动把中文编码了。<div class="code">echo json_encode(&quot;厦门&quot;, JSON_UNESCAPED_UNICODE);</div><br/><br/>另，由于 json_encode 和 json_decode只支持utf-8编码的字符，GBK的字符要用json就得转换一下，附自己写的GBK转UTF-8的代码：<div class="code"><br/>/*<br/>&nbsp;&nbsp;&nbsp;&nbsp;字符串GBK转码为UTF-8，数字转换为数字。<br/>*/<br/>function ct2($s)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;if(is_numeric($s)) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return intval($s);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125; else &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return iconv(&quot;GBK&quot;,&quot;UTF-8&quot;,$s);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&#125;<br/>/*<br/>&nbsp;&nbsp;&nbsp;&nbsp;批量处理gbk-&gt;utf-8<br/>*/<br/>function icon_to_utf8($s) &#123;<br/><br/>&nbsp;&nbsp;if(is_array($s)) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;foreach($s as $key =&gt; $val) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$s&#91;$key&#93; = icon_to_utf8($val);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&#125; else &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$s = ct2($s);<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;return $s;<br/><br/>&#125;<br/><br/>echo json_encode(icon_to_utf8(&quot;厦门&quot;));</div><br/>Tags - <a href="http://www.9enjoy.com/tags/%25E7%25BC%2596%25E7%25A0%2581/" rel="tag">编码</a> , <a href="http://www.9enjoy.com/tags/json/" rel="tag">json</a> , <a href="http://www.9enjoy.com/tags/%25E4%25B8%25AD%25E6%2596%2587/" rel="tag">中文</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/curl_get_contents/</link>
<title><![CDATA[分享比file_get_contents稳定的curl_get_contents]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Tue, 03 Jan 2012 12:29:06 +0000</pubDate> 
<guid>http://www.9enjoy.com/curl_get_contents/</guid> 
<description>
<![CDATA[ 
	分享一个实际在用的函数：<br/><div class="code">/*比file_get_contents稳定的多！$timeout为超时时间，单位是秒，默认为1s。*/<br/>function curl_get_contents($url,$timeout=1) &#123;<br/>&nbsp;&nbsp;$curlHandle = curl_init();<br/>&nbsp;&nbsp;curl_setopt( $curlHandle , CURLOPT_URL, $url );<br/>&nbsp;&nbsp;curl_setopt( $curlHandle , CURLOPT_RETURNTRANSFER, 1 );<br/>&nbsp;&nbsp;curl_setopt( $curlHandle , CURLOPT_TIMEOUT, $timeout );<br/>&nbsp;&nbsp;$result = curl_exec( $curlHandle );<br/>&nbsp;&nbsp;curl_close( $curlHandle );<br/>&nbsp;&nbsp;return $result;<br/>&#125;<br/>$hx = curl_get_contents(&#039;http://www.9enjoy.com&#039;);</div><br/>相信使用过file_get_contents函数的朋友都知道，当获取的$url访问不了时，会导致页面漫长的等待，甚至还能导致PHP进程占用CPU达100%，因此这个函数就诞生了。<a href="http://www.9enjoy.com/post/300" target="_blank">curl的一些常识介绍</a><br/><br/>保留原file_get_contents函数的原因是当读取本地文件时，用原生的file_get_contents显然更合适。<br/><br/>另来自张宴的file_get_contnets的优化，具体可看：<a href="http://blog.s135.com/file_get_contents" target="_blank">http://blog.s135.com/file_get_contents</a><br/>同样是设置超时时间来解决这个问题。如果没装curl，就必须得用这个方式了。<br/><div class="code">$ctx = stream_context_create(array(&nbsp;&nbsp; <br/>&nbsp;&nbsp; &#039;http&#039; =&gt; array(&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039;timeout&#039; =&gt; 1 //设置一个超时时间，单位为秒&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )&nbsp;&nbsp; <br/>&nbsp;&nbsp; )&nbsp;&nbsp; <br/>);&nbsp;&nbsp; <br/>file_get_contents(&quot;http://www.9enjoy.com/&quot;, 0, $ctx); </div><br/><br/>另外，据不完全测试，使用curl获取页面比用file_get_contents稳定的多。<br/><br/><br/>Tags - <a href="http://www.9enjoy.com/tags/curl/" rel="tag">curl</a> , <a href="http://www.9enjoy.com/tags/%25E9%2587%2587%25E9%259B%2586/" rel="tag">采集</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/no-deserializer-defined-for-array-type/</link>
<title><![CDATA[ArrayOf_xsd_string格式在php下的处理]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Mon, 07 Nov 2011 06:51:56 +0000</pubDate> 
<guid>http://www.9enjoy.com/no-deserializer-defined-for-array-type/</guid> 
<description>
<![CDATA[ 
	使用某服务商的webservice服务，其wsdl里有个这样一个变量： <br/>&lt;&lt;wsdl:part name=&quot;mobiles&quot; type=&quot;impl:ArrayOf_xsd_string&quot; /&gt; <br/>而php里并没有对应的类型。<br/>使用<br/>$mobiles = &#039;18900000000&#039;;<br/>$mobiles[0]=&#039;18900000000&#039;;<br/>甚至mobiles[0][0]=&#039;18900000000&#039;;<br/>都不行，会提示：<br/>Fatal error: Uncaught SoapFault exception: [soapenv:Server.userException] org.xml.sax.SAXException: No deserializer defined for array type &#123;<a href="http://www.w3.org/2001/XMLSchema&#125;string" target="_blank">http://www.w3.org/2001/XMLSchema&#125;string</a> in /www/9enjoy.com/include/hx.php:46 Stack trace: #0 /www/9enjoy.com/include/hx.php(46): SoapClient-&gt;__call(&#039;sendSM&#039;, Array) #1 /www/9enjoy.com/include/hx.php(2): send_mobile(&#039;18900000000&#039;, &#039;&#123;????????&#125;?????...&#039;) #2 &#123;main&#125; thrown in /www/9enjoy.com/include/hx.php on line 46<br/><br/>使用.NET WebService Studio工具测试，将参数填入后，得到request的xml为：<br/><br/>&lt;q1:sendSM&gt;<br/><br/>​&nbsp;&nbsp;&nbsp;&nbsp;&lt;mobiles href=&quot;#id1&quot; /&gt;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;content xsi:type=&quot;xsd:string&quot;&gt;test&lt;/content&gt;​<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;...<br/><br/>&lt;/qi:sendSM&gt;<br/><br/>&lt;soapenc:Array id=&quot;id1&quot; soapenc:arrayType=&quot;xsd:string[1]&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Item&gt;18900000000&lt;/Item&gt;<br/>&lt;/soapenc:Array&gt;<br/><br/><br/>测试多次后发现有两种解决办法：<br/><br/>1.较简单，把ArrayOf_xsd_string这种格式转换为数组格式<br/><br/>&lt;?php<br/>$client = new SoapClient(&quot;some.wsdl&quot;, array(&#039;features&#039; =&gt; SOAP_USE_XSI_ARRAY_TYPE));<br/>?&gt; <br/><br/>这时，可使用$mobiles = array(&#039;18900000000&#039;);来传递$mobiles变量。<br/>这是php5.2.2起增加的功能<div class="quote"><div class="quote-title">引用</div><div class="quote-content">- Improved SOAP<br/>&nbsp;&nbsp;. Added ability to encode arrays with &quot;SOAP-ENC:Array&quot; type instead of WSDL<br/>&nbsp;&nbsp;&nbsp;&nbsp;type. To activate the ability use &quot;feature&quot;=&gt;SOAP_USE_XSI_ARRAY_TYPE<br/>&nbsp;&nbsp;&nbsp;&nbsp;option in SoapClient/SoapServer constructors. (Rob, Dmitry)</div></div><br/><br/>2.将整个xml文档用doRequest 方法发送出去<br/><br/>public string SoapClient::__doRequest ( string $request , string $location , string $action , int $version [, int $one_way = 0 ] )<br/>Tags - <a href="http://www.9enjoy.com/tags/array/" rel="tag">array</a> , <a href="http://www.9enjoy.com/tags/soap/" rel="tag">soap</a> , <a href="http://www.9enjoy.com/tags/php/" rel="tag">php</a> , <a href="http://www.9enjoy.com/tags/websevice/" rel="tag">websevice</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/trying-to-clone-uncloneable-object-of-class/</link>
<title><![CDATA[Trying to clone an uncloneable object of class Imagic的解决]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Sun, 25 Sep 2011 10:14:51 +0000</pubDate> 
<guid>http://www.9enjoy.com/trying-to-clone-uncloneable-object-of-class/</guid> 
<description>
<![CDATA[ 
	使用网上流传的一个程序实现pdf截图为png，需要使用Imagic扩展。在windows下安装完后提示：<div class="code">Fatal error: Trying to clone an uncloneable object of class Imagick in C:&#92;www&#92;hx&#92;pdf_to_png.php on line 17</div><br/><br/>使用IIS和Apache均会有这个提示。经多次测试后，发现两种解决方法:<br/><br/>1.php.ini中; Enable compatibility mode with Zend Engine 1 (PHP 4.x)<br/>zend.ze1_compatibility_mode = Off<br/><br/>默认是On，改为Off后，即可解决。<br/><br/>2.使用imagick::...这种方法调用。<br/>即$im-&gt;setResolution(120, 120);可以改写为：<br/>imagick::setResolution(120, 120);<br/><br/><br/>如果其它扩展出现这类错误，一般也是可以使用这两种方法解决的。<br/><br/>附pdf转png的程序代码片断：<div class="code">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function pdf2png($pdf, $filename, $page=0) &#123;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!extension_loaded(&#039;imagick&#039;)) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(&#039;no imagick&#039;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!file_exists($pdf)) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im = new Imagick();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;setResolution(120, 120);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;setCompressionQuality(100);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;readImage($pdf . &quot;&#91;&quot; . $page . &quot;&#93;&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;setImageFormat(&#039;png&#039;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;writeImage($filename);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;readImage($filename);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;resizeImage(120, 150, Imagick::FILTER_LANCZOS, 1);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;writeImage($filename);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $filename;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;</div><br/><br/> <br/>Tags - <a href="http://www.9enjoy.com/tags/%25E6%2589%25A9%25E5%25B1%2595/" rel="tag">扩展</a>
]]>
</description>
</item>
</channel>
</rss>