<?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>PHP 4u Web developer - 代码的简化 &#187; php</title>
	<atom:link href="http://php4u.co.uk/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://php4u.co.uk</link>
	<description>PHP related blog, freelancer to hire!</description>
	<lastBuildDate>Fri, 30 Jul 2010 14:13:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Testlink 1.9 problem with Charts &#8211; Error 500</title>
		<link>http://php4u.co.uk/2010/07/testlink-1-9-problem-with-charts-error-500/</link>
		<comments>http://php4u.co.uk/2010/07/testlink-1-9-problem-with-charts-error-500/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 14:12:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[fatal errors]]></category>
		<category><![CDATA[Testlink]]></category>

		<guid isPermaLink="false">http://php4u.co.uk/?p=151</guid>
		<description><![CDATA[Today I faced problem with Testlink 1.9 &#8211; while clicking on Test Results &#62; Charts I&#8217;ve got : PHP Fatal error: require_once() [function.require]: Failed opening required '/var/www/html/testlink/cfg/.cfg.php' (include_path='.:/usr/share/pear:.:/var/www/html/testlink/lib/functions/:/var/www/html/testlink/third_party/') in /var/www/html/testlink/lib/bugtracking/int_bugtracking.php on line 367, referer: http://xxxxxx/testlink/lib/results/resultsNavigator.php If you have similar edit /var/www/html/testlink/lib/bugtracking/int_bugtracking.php Line 363: $btsname = strtolower($bts_type); Dirty, but works Line]]></description>
			<content:encoded><![CDATA[<p>Today I faced problem with Testlink 1.9 &#8211; while clicking on <strong>Test Results</strong> &gt; <strong>Charts</strong> I&#8217;ve got :</p>
<p><code> PHP Fatal error:  require_once() [<a href="function.require">function.require</a>]: Failed opening required '/var/www/html/testlink/cfg/.cfg.php' (include_path='.:/usr/share/pear:.:/var/www/html/testlink/lib/functions/:/var/www/html/testlink/third_party/') in /var/www/html/testlink/lib/bugtracking/int_bugtracking.php on line 367, referer: http://xxxxxx/testlink/lib/results/resultsNavigator.php<br />
</code></p>
<p>If you have similar edit <strong>/var/www/html/testlink/lib/bugtracking/int_bugtracking.php </strong></p>
<p><code>Line 363:  $btsname = strtolower($bts_type);</code></p>
<p>Dirty, but works</p>
<p><strong><strong>Line</strong><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://php4u.co.uk/2010/07/testlink-1-9-problem-with-charts-error-500/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prime numbers in PHP &#8211; quick and efficient way</title>
		<link>http://php4u.co.uk/2010/07/prime-numbers-in-php-quick-and-efficient-way/</link>
		<comments>http://php4u.co.uk/2010/07/prime-numbers-in-php-quick-and-efficient-way/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 08:19:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[prime numbers]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://php4u.co.uk/?p=139</guid>
		<description><![CDATA[Looking for a way to find prime numbers in php? I wfound one perl solution here, but it wasn&#8217;t perl magic &#8211; it was power of regular expressions. Please find code below which will be self-explanatory. &#60;?php /** * Function checks if given number is prime * * @param integer $n * @return boolean */ [...]]]></description>
			<content:encoded><![CDATA[<p>Looking for a way to find prime numbers in php? I wfound one perl solution <a title="Prime numbers in perl" href="http://montreal.pm.org/tech/neil_kandalgaonkar.shtml" target="_blank">here</a>, but it wasn&#8217;t perl magic &#8211; it was power of regular expressions.</p>
<p>Please find code below which will be self-explanatory.</p>
<p><code lang="php"><br />
&lt;?php</code></p>
<p>/**<br />
* Function checks if given number is prime<br />
*<br />
* @param integer $n<br />
* @return boolean<br />
*/<br />
function isPrime($n) {<br />
return (!preg_match(&#8216;/^1?$|^(11+?)\1+$/x&#8217;, str_repeat(&#8217;1&#8242;, intval($n)))) ;<br />
}</p>
<p>for ($n=0;$n&lt;100;$n++) {<br />
echo &#8220;Number {$n} is &#8220;.(isPrime($n) ? &#8216;prime&#8217; : &#8216;not prime&#8217;).&#8221;&lt;br/&gt;\n&#8221;;<br />
}</p>
<p>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://php4u.co.uk/2010/07/prime-numbers-in-php-quick-and-efficient-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use PHP and PDO to connect to MS SQL Server (Zend Framework)</title>
		<link>http://php4u.co.uk/2010/06/use-php-and-pdo-to-connect-to-ms-sql-server-zend-framework/</link>
		<comments>http://php4u.co.uk/2010/06/use-php-and-pdo-to-connect-to-ms-sql-server-zend-framework/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 15:03:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[Microsoft SQL]]></category>
		<category><![CDATA[PDO]]></category>
		<category><![CDATA[php5]]></category>

		<guid isPermaLink="false">http://php4u.co.uk/?p=126</guid>
		<description><![CDATA[Problems connecting to MS SQL server from Zend Framework? Message: The mssql driver is not currently installed Solution is simple Install pdo_mssql driver: (Ubuntu) ?View Code BASH#sudo apt-get install php5-sybase #sudo /etc/init.d/apache2 restart On Centos you need to install pdo_dblib (any problems check here) It will not reflect in phpinfo() page Trick is to setup [...]]]></description>
			<content:encoded><![CDATA[<p>Problems connecting to MS SQL server from Zend Framework?</p>
<p><strong>Message:</strong> The mssql driver is not currently installed</p>
<p>Solution is simple</p>
<p>Install pdo_mssql driver: (Ubuntu)</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p126code3'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1263"><td class="code" id="p126code3"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#sudo apt-get install php5-sybase</span>
<span style="color: #666666; font-style: italic;">#sudo /etc/init.d/apache2 restart</span></pre></td></tr></table></div>

<p>On Centos you need to install pdo_dblib (any problems check <a href="http://www.richardhyland.com/diary/2009/02/25/two-days-with-pdo-and-my-lack-of-faith-in-the-php-extension-developers/" target="_blank">here</a>)</p>
<p>It will not reflect in phpinfo() page</p>
<p>Trick is to setup connection properly:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p126code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1264"><td class="code" id="p126code4"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$dbAdapter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Db_Adapter_Pdo_Mssql<span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
 <span style="color: #0000ff;">'host'</span>     <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'192.xxx.xxx.xxx'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// parklife</span>
 <span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'xxx'</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'xxx'</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'dbname'</span>   <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'xxx'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'pdoType'</span>  <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span>  <span style="color: #0000ff;">'dblib'</span> <span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://php4u.co.uk/2010/06/use-php-and-pdo-to-connect-to-ms-sql-server-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &amp; MongoDB Sitting in a Tree: Part 1</title>
		<link>http://php4u.co.uk/2010/05/php-mongodb-sitting-in-a-tree-part-1/</link>
		<comments>http://php4u.co.uk/2010/05/php-mongodb-sitting-in-a-tree-part-1/#comments</comments>
		<pubDate>Fri, 14 May 2010 15:23:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[php mongodb tutorial example]]></category>

		<guid isPermaLink="false">http://php4u.co.uk/2010/05/php-mongodb-sitting-in-a-tree-part-1/</guid>
		<description><![CDATA[Always wanted to try it, nice tutorial here http://www.dealtaker.com/blog/2010/05/12/php-mongodb-sitting-in-a-tree-part-1/]]></description>
			<content:encoded><![CDATA[<p>Always wanted to try it, nice tutorial here<br />
<a title="MongoDB tutorial part 1" href="http://www.dealtaker.com/blog/2010/05/12/php-mongodb-sitting-in-a-tree-part-1/" target="_blank">http://www.dealtaker.com/blog/2010/05/12/php-mongodb-sitting-in-a-tree-part-1/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://php4u.co.uk/2010/05/php-mongodb-sitting-in-a-tree-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What should a developer know before building a public web site?</title>
		<link>http://php4u.co.uk/2010/04/what-should-a-developer-know-before-building-a-public-web-site/</link>
		<comments>http://php4u.co.uk/2010/04/what-should-a-developer-know-before-building-a-public-web-site/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 09:06:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Browsers issues]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[useful info about developement]]></category>

		<guid isPermaLink="false">http://php4u.co.uk/?p=120</guid>
		<description><![CDATA[&#8220;The idea here is that most of us should already know most of what is on this list. But there just might be one or two items you haven&#8217;t really looked into before, don&#8217;t fully understand, or maybe never even heard of.&#8221; Great article here]]></description>
			<content:encoded><![CDATA[<p>&#8220;The idea here is that most of us should <em>already</em> know <em>most</em> of what is on this list.  But there just might be one or two items you  haven&#8217;t really looked into before, don&#8217;t fully understand, or maybe  never even heard of.&#8221;</p>
<p>Great article <a title="What should a developer know before building a public web site?" href="http://stackoverflow.com/questions/72394/what-should-a-developer-know-before-building-a-public-web-site" target="_blank">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://php4u.co.uk/2010/04/what-should-a-developer-know-before-building-a-public-web-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run PHP (and others) code in a browser &#8211; revolutionary pastebin</title>
		<link>http://php4u.co.uk/2009/12/run-php-and-others-code-in-a-browser-revolutionary-pastebin/</link>
		<comments>http://php4u.co.uk/2009/12/run-php-and-others-code-in-a-browser-revolutionary-pastebin/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 12:52:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[code in browser]]></category>
		<category><![CDATA[code testing]]></category>
		<category><![CDATA[pastebin]]></category>

		<guid isPermaLink="false">http://php4u.co.uk/?p=112</guid>
		<description><![CDATA[If you need to test a code in browser &#8211; try  http://ideone.com/ Entry found on http://alouche.net/blog/2009/11/24/ideone-compiler-pastebin/]]></description>
			<content:encoded><![CDATA[<p>If you need to test a code in browser &#8211; try  <a href="http://ideone.com/">http://ideone.com/</a></p>
<p>Entry found on http://alouche.net/blog/2009/11/24/ideone-compiler-pastebin/</p>
]]></content:encoded>
			<wfw:commentRss>http://php4u.co.uk/2009/12/run-php-and-others-code-in-a-browser-revolutionary-pastebin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Geotagging script</title>
		<link>http://php4u.co.uk/2009/08/geotagging-script/</link>
		<comments>http://php4u.co.uk/2009/08/geotagging-script/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 20:48:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[geotagging]]></category>
		<category><![CDATA[user stats]]></category>
		<category><![CDATA[visitors live stats]]></category>

		<guid isPermaLink="false">http://php4u.co.uk/?p=98</guid>
		<description><![CDATA[Geotagging script (http://themeforest.net/user/php4ucouk) Script converts visitor&#8217;s ip adress into : country code (2 and 3 letter ISO code) full english country name region code and name currency code used in this country postal code gps coordinates area code dma code metro code and BONUS overall statitics about users from different countries number or live visitors [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Geotagging script </strong>(http://themeforest.net/user/php4ucouk)</p>
<p>Script converts visitor&#8217;s ip adress into :</p>
<ul>
<li> country code (2 and 3 letter ISO code)</li>
</ul>
<ul>
<li> full english country name</li>
</ul>
<ul>
<li> region code and name</li>
</ul>
<ul>
<li> currency code used in this country</li>
</ul>
<ul>
<li> postal code</li>
</ul>
<ul>
<li> gps coordinates</li>
</ul>
<ul>
<li> area code</li>
</ul>
<ul>
<li> dma code</li>
</ul>
<ul>
<li> metro code</li>
</ul>
<p><strong>and BONUS</strong></p>
<ul>
<li> overall statitics about users from different countries</li>
</ul>
<ul>
<li> number or live visitors on your web page</li>
</ul>
<p>Data is provided to you, so you can use it (display it, store in db or do whatever you need)</p>
<p><strong><a title="Geotagging live demo" href="http://php4u.co.uk/geotagging/demo.php" target="_blank">Live demo</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://php4u.co.uk/2009/08/geotagging-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Mail problem on Ubuntu</title>
		<link>http://php4u.co.uk/2009/05/php-mail-problem-on-ubuntu/</link>
		<comments>http://php4u.co.uk/2009/05/php-mail-problem-on-ubuntu/#comments</comments>
		<pubDate>Fri, 29 May 2009 14:39:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[sendmail]]></category>

		<guid isPermaLink="false">http://php4u.co.uk/?p=89</guid>
		<description><![CDATA[I&#8217;ve installed fresh version of Ubuntu 9.04 with Lamp, but I couldn&#8217;t send emails outside. Problem was SMTP auth of outgoing server, spending time found http://dbaron.org/linux/sendmail who made my day. Thanks]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve installed fresh version of Ubuntu 9.04 with Lamp, but I couldn&#8217;t send emails outside.</p>
<p>Problem was SMTP auth of outgoing server, spending time found <a title="Sendmail SMTP conf" href="http://dbaron.org/linux/sendmail" target="_blank">http://dbaron.org/linux/sendmail</a> who made my day. Thanks</p>
]]></content:encoded>
			<wfw:commentRss>http://php4u.co.uk/2009/05/php-mail-problem-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logging page rendering time in Symfony 1.xx</title>
		<link>http://php4u.co.uk/2009/03/logging-page-rendering-time-in-symfony-1xx/</link>
		<comments>http://php4u.co.uk/2009/03/logging-page-rendering-time-in-symfony-1xx/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 13:07:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[optimisation]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://php4u.co.uk/?p=72</guid>
		<description><![CDATA[Change your SF_APP/web/index.php file to be: ?View Code PHP$timer = sfTimerManager::getTimer&#40;'myTimer'&#41;; sfContext::getInstance&#40;&#41;-&#38;gt;getController&#40;&#41;-&#38;gt;dispatch&#40;&#41;; $timer-&#38;gt;addTime&#40;&#41;; $elapsedTime = $timer-&#38;gt;getElapsedTime&#40;&#41;; $fullRealUri = str_replace&#40; sfContext::getInstance&#40;&#41;-&#38;gt;getRequest&#40;&#41;-&#38;gt;getUriPrefix&#40;&#41;, &#34;&#34;, sfContext::getInstance&#40;&#41;-&#38;gt;getRequest&#40;&#41;-&#38;gt;getUri&#40;&#41;&#41;; file_put_contents&#40;'/tmp/time.log',date&#40;'Y-m-d H:i:s'&#41;.&#34;&#124;$fullRealUri&#124;$elapsedTime\n\r&#34;,FILE_APPEND&#41;;]]></description>
			<content:encoded><![CDATA[<p>Change your SF_APP/web/index.php file to be:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p72code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p726"><td class="code" id="p72code6"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$timer</span> <span style="color: #339933;">=</span> sfTimerManager<span style="color: #339933;">::</span><span style="color: #004000;">getTimer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'myTimer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
sfContext<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getController<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>dispatch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$timer</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>addTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$elapsedTime</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$timer</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getElapsedTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fullRealUri</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span> sfContext<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getUriPrefix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> sfContext<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getUri<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/file_put_contents"><span style="color: #990000;">file_put_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/tmp/time.log'</span><span style="color: #339933;">,</span><a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;|<span style="color: #006699; font-weight: bold;">$fullRealUri</span>|<span style="color: #006699; font-weight: bold;">$elapsedTime</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">,</span>FILE_APPEND<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://php4u.co.uk/2009/03/logging-page-rendering-time-in-symfony-1xx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sFTP for PHP 5.xx</title>
		<link>http://php4u.co.uk/2009/03/sftp-for-php-5xx/</link>
		<comments>http://php4u.co.uk/2009/03/sftp-for-php-5xx/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 12:51:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[sftp]]></category>
		<category><![CDATA[ssh3]]></category>

		<guid isPermaLink="false">http://php4u.co.uk/?p=62</guid>
		<description><![CDATA[Install SSh2 extension for PHP, then you can use class below: ?View Code PHP&#38;lt;?php /** * Class to deal with sFTP connections * to use install http://php.oregonstate.edu/manual/en/ssh2.installation.php * */ class SFTPConnection &#123; private $connection; private $sftp; &#160; public function __construct&#40;$host, $port=22&#41; &#123; if &#40;!extension_loaded&#40;'ssh2'&#41;&#41; &#123; throw new Exception&#40;&#34;Extension ssh2 has to be loaded to use [...]]]></description>
			<content:encoded><![CDATA[<p>Install SSh2 extension for PHP, then you can use class below:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p62code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p628"><td class="code" id="p62code8"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>?php
<span style="color: #009933; font-style: italic;">/**
 * Class to deal with sFTP connections
 * to use install http://php.oregonstate.edu/manual/en/ssh2.installation.php
 *
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> SFTPConnection
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$connection</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$sftp</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #339933;">,</span> <span style="color: #000088;">$port</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">22</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/extension_loaded"><span style="color: #990000;">extension_loaded</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ssh2'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        	<span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Extension ssh2 has to be loaded to use this class. Please enable in php.ini.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    	<span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection <span style="color: #339933;">=</span> <a href="http://www.php.net/ssh2_connect"><span style="color: #990000;">ssh2_connect</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #339933;">,</span> <span style="color: #000088;">$port</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span>
            <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Could not connect to <span style="color: #006699; font-weight: bold;">$host</span> on port <span style="color: #006699; font-weight: bold;">$port</span>.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> login<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/extension_loaded"><span style="color: #990000;">extension_loaded</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ssh2'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        	<span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Extension ssh2 has to be loaded to use this class. Please enable in php.ini.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #339933;">@</span><a href="http://www.php.net/ssh2_auth_password"><span style="color: #990000;">ssh2_auth_password</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #339933;">,</span> <span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Could not authenticate with username <span style="color: #006699; font-weight: bold;">$username</span> &quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;and password <span style="color: #006699; font-weight: bold;">$password</span>.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>sftp <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/ssh2_sftp"><span style="color: #990000;">ssh2_sftp</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>sftp<span style="color: #009900;">&#41;</span>
            <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Could not initialize SFTP subsystem.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> uploadFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$local_file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$remote_file</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/extension_loaded"><span style="color: #990000;">extension_loaded</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ssh2'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        	<span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Extension ssh2 has to be loaded to use this class. Please enable in php.ini.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    	<span style="color: #000088;">$sftp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>sftp<span style="color: #339933;">;</span>
        <span style="color: #000088;">$stream</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ssh2.sftp://<span style="color: #006699; font-weight: bold;">$sftp</span><span style="color: #006699; font-weight: bold;">$remote_file</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$stream</span><span style="color: #009900;">&#41;</span>
            <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Could not open file: <span style="color: #006699; font-weight: bold;">$remote_file</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$data_to_send</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$local_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data_to_send</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
            <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Could not open local file: <span style="color: #006699; font-weight: bold;">$local_file</span>.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><a href="http://www.php.net/fwrite"><span style="color: #990000;">fwrite</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stream</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data_to_send</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
            <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Could not send data from file: <span style="color: #006699; font-weight: bold;">$local_file</span>.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #339933;">@</span><a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stream</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> scanFilesystem<span style="color: #009900;">&#40;</span><span style="color: #000088;">$remote_file</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/extension_loaded"><span style="color: #990000;">extension_loaded</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ssh2'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	        <span style="color: #009900;">&#123;</span>
	        	<span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Extension ssh2 has to be loaded to use this class. Please enable in php.ini.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	        <span style="color: #009900;">&#125;</span>
        	<span style="color: #000088;">$sftp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>sftp<span style="color: #339933;">;</span>
            <span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ssh2.sftp://<span style="color: #006699; font-weight: bold;">$sftp</span><span style="color: #006699; font-weight: bold;">$remote_file</span>&quot;</span><span style="color: #339933;">;</span>
              <span style="color: #000088;">$tempArray</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/opendir"><span style="color: #990000;">opendir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #666666; font-style: italic;">// List all the files</span>
            <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/readdir"><span style="color: #990000;">readdir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$file</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
              <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color: #990000;">is_dir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//                $tempArray[$file] = $this-&amp;gt;scanFilesystem(&quot;$dir/$file&quot;);</span>
               <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                 <span style="color: #000088;">$tempArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span>
             <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
           <a href="http://www.php.net/closedir"><span style="color: #990000;">closedir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #b1b100;">return</span> <span style="color: #000088;">$tempArray</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>   
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> receiveFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$remote_file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$local_file</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/extension_loaded"><span style="color: #990000;">extension_loaded</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ssh2'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        	<span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Extension ssh2 has to be loaded to use this class. Please enable in php.ini.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    	<span style="color: #000088;">$sftp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>sftp<span style="color: #339933;">;</span>
        <span style="color: #000088;">$stream</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ssh2.sftp://<span style="color: #006699; font-weight: bold;">$sftp</span><span style="color: #006699; font-weight: bold;">$remote_file</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$stream</span><span style="color: #009900;">&#41;</span>
            <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Could not open file: <span style="color: #006699; font-weight: bold;">$remote_file</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$contents</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/fread"><span style="color: #990000;">fread</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stream</span><span style="color: #339933;">,</span> <a href="http://www.php.net/filesize"><span style="color: #990000;">filesize</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ssh2.sftp://<span style="color: #006699; font-weight: bold;">$sftp</span><span style="color: #006699; font-weight: bold;">$remote_file</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <a href="http://www.php.net/file_put_contents"><span style="color: #990000;">file_put_contents</span></a> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$local_file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$contents</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #339933;">@</span><a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stream</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> deleteFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$remote_file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/extension_loaded"><span style="color: #990000;">extension_loaded</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ssh2'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
      	<span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Extension ssh2 has to be loaded to use this class. Please enable in php.ini.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #000088;">$sftp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>sftp<span style="color: #339933;">;</span>
      <a href="http://www.php.net/unlink"><span style="color: #990000;">unlink</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ssh2.sftp://<span style="color: #006699; font-weight: bold;">$sftp</span><span style="color: #006699; font-weight: bold;">$remote_file</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://php4u.co.uk/2009/03/sftp-for-php-5xx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.255 seconds -->
