<?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>Aris Royo &#187; PHP</title>
	<atom:link href="http://arisroyo.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://arisroyo.com</link>
	<description>Web programming is just a hobby.</description>
	<lastBuildDate>Fri, 18 May 2012 13:06:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>When Internet Goes Dark [SOPA]</title>
		<link>http://arisroyo.com/2012/01/20/when-internet-goes-dark-sopa/</link>
		<comments>http://arisroyo.com/2012/01/20/when-internet-goes-dark-sopa/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 00:00:58 +0000</pubDate>
		<dc:creator>Aris Royo</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Free Software]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[FSF]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Headline]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[sopa]]></category>
		<category><![CDATA[wikipedia]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://arisroyo.com/?p=641</guid>
		<description><![CDATA[January 18, 2012 when internet goes dark againts Internet Censorship in US, the free software community had launch a 24 hours campaign to protest SOPA known as H.R 3261. With the power of internet and online community shows how intenet is really amazing fsf.org, libreplanet.org, php.net, google.com, wordpress.org, wikipedia and other internet services goes black [...]]]></description>
			<content:encoded><![CDATA[<p>January 18, 2012 when internet goes dark againts Internet Censorship in US, the free software community had launch a 24 hours campaign to protest SOPA known as H.R 3261.</p>
<p>With the power of internet and online community shows how intenet is really amazing fsf.org, libreplanet.org, php.net, google.com, wordpress.org, wikipedia and other internet services goes black that&#8217;s gives blackeye to SOPA to pull out by it&#8217;s chief sponsor.</p>
<p>Here is some screenshot I get that show how internet is really great.</p>
<p><a href="http://arisroyo.com/wp-content/uploads/2012/01/fsf.png"><img src="http://arisroyo.com/wp-content/uploads/2012/01/fsf-300x169.png" alt="" title="fsf.org" width="300" height="169" class="alignleft size-medium wp-image-642" /></a></p>
<p><a href="http://arisroyo.com/wp-content/uploads/2012/01/google.png"><img src="http://arisroyo.com/wp-content/uploads/2012/01/google-300x167.png" alt="" title="google.com" width="300" height="167" class="alignleft size-medium wp-image-646" /></a></p>
<p><a href="http://arisroyo.com/wp-content/uploads/2012/01/php.png"><img src="http://arisroyo.com/wp-content/uploads/2012/01/php-300x169.png" alt="" title="php.net" width="300" height="169" class="alignleft size-medium wp-image-648" /></a></p>
<p><a href="http://arisroyo.com/wp-content/uploads/2012/01/wikipedia.png"><img src="http://arisroyo.com/wp-content/uploads/2012/01/wikipedia-300x170.png" alt="" title="wikipedia" width="300" height="170" class="alignleft size-medium wp-image-649" /></a></p>
<p><a href="http://arisroyo.com/wp-content/uploads/2012/01/wordpress.png"><img src="http://arisroyo.com/wp-content/uploads/2012/01/wordpress-300x166.png" alt="" title="wordpress.org" width="300" height="166" class="alignleft size-medium wp-image-650" /></a></p>
<h2  class="related_post_title">Related Topic</h2><ul class="related_post"><li><a href="http://arisroyo.com/2012/04/19/join-us-in-working-to-eliminate-drm/" title="Join us in working to eliminate DRM!">Join us in working to eliminate DRM!</a></li><li><a href="http://arisroyo.com/2011/12/03/youre-invited-to-join-libreplanet-philippines/" title="You&#8217;re Invited To Join LibrePlanet Philippines">You&#8217;re Invited To Join LibrePlanet Philippines</a></li><li><a href="http://arisroyo.com/2012/01/12/php-w3schools-certified/" title="PHP w3Schools Certified">PHP w3Schools Certified</a></li><li><a href="http://arisroyo.com/2011/10/18/defend-the-freedom-to-install-free-software/" title="Defend The Freedom To Install Free Software">Defend The Freedom To Install Free Software</a></li><li><a href="http://arisroyo.com/2011/05/12/php-is-a-templating-language/" title="PHP Is A Templating Language">PHP Is A Templating Language</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://arisroyo.com/2012/01/20/when-internet-goes-dark-sopa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP w3Schools Certified</title>
		<link>http://arisroyo.com/2012/01/12/php-w3schools-certified/</link>
		<comments>http://arisroyo.com/2012/01/12/php-w3schools-certified/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 01:28:32 +0000</pubDate>
		<dc:creator>Aris Royo</dc:creator>
				<category><![CDATA[Tech Life]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[w3school]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://arisroyo.com/?p=652</guid>
		<description><![CDATA[I finally completed and passed the w3schools PHP &#038; MySQL certification, even I heard the w3fools claims againts w3school. I still continue to get the certification, first because it&#8217;s already my plan since last year, second PHP is not their concern and third its just for a PHP foundation and I would like to get [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.refsnesdata.no/certification/w3certified.asp?id=3239427"><img src="http://arisroyo.com/wp-content/uploads/2012/01/w3certified_biglogo-300x101.png" alt="" title="w3certified" width="300" height="101" class="alignright size-medium wp-image-668" /></a>I finally completed and passed the w3schools PHP &#038; MySQL certification, even I heard the w3fools claims againts w3school.</p>
<p>I still continue to get the certification, first because it&#8217;s already my plan since last year, second PHP is not their concern and third its just for a PHP foundation and I would like to get PHP certification while I &#8216;m still waiting for php 5.4 and finally get the certification on Zend.</p>
<p>The w3school offer is good enough to document my knowledge in PHP, The exam is quite good not easy but never to tough is 70 random question about PHP and MySQL.</p>
<p>I passed the exam but to far to get perfect score or to get the Excellency Degree notation for those who get 95%.</p>
<p>Overall is good experience and nice to have PHP certification, I can&#8217;t wait to PHP Zend Certifcation but I still need to wait for PHP5.4 to come.</p>
<h2  class="related_post_title">Related Topic</h2><ul class="related_post"><li><a href="http://arisroyo.com/2012/01/20/when-internet-goes-dark-sopa/" title="When Internet Goes Dark [SOPA]">When Internet Goes Dark [SOPA]</a></li><li><a href="http://arisroyo.com/2011/05/12/php-is-a-templating-language/" title="PHP Is A Templating Language">PHP Is A Templating Language</a></li><li><a href="http://arisroyo.com/2011/05/06/install-and-configure-lamp-linux-apache-mysql-php/" title="Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]">Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]</a></li><li><a href="http://arisroyo.com/2011/05/05/shop-pay-cash-facebook-apps/" title="Shop &#038; Pay Cash &#8211; Facebook Apps">Shop &#038; Pay Cash &#8211; Facebook Apps</a></li><li><a href="http://arisroyo.com/2011/03/25/php-curl-example/" title="PHP cURL Example">PHP cURL Example</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://arisroyo.com/2012/01/12/php-w3schools-certified/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Is A Templating Language</title>
		<link>http://arisroyo.com/2011/05/12/php-is-a-templating-language/</link>
		<comments>http://arisroyo.com/2011/05/12/php-is-a-templating-language/#comments</comments>
		<pubDate>Thu, 12 May 2011 00:00:57 +0000</pubDate>
		<dc:creator>Aris Royo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.arisroyo.com/?p=475</guid>
		<description><![CDATA[I found out this blog post from Terry Chay he is a PHP developer and advocate, this is one of his post about the important about PHP as programming language. PHP is a templating language, not a general purpose or even an object oriented language. Embrace it. Don&#8217;t fight it; Don&#8217;t introduce frameworks just for [...]]]></description>
			<content:encoded><![CDATA[<p>I found out this blog post from <a href="http://terrychay.com/">Terry Chay</a> he is a PHP developer and advocate, this is one of his post about the important about PHP as programming language.</p>
<p>PHP is a templating language, not a general purpose or even an object oriented language. Embrace it. Don&#8217;t fight it;</p>
<p>Don&#8217;t introduce frameworks just for the sake of them. This goes back to the fundamental principle that you shouldn&#8217;t solve a problem until you have a problem. Developers these days I find are somewhat &#8220;framework trigger happy&#8221; (&#8220;I&#8217;m sick of writing if (s == null || s.equals(&#8220;&#8221;)), lets add Apache Commons Validator to the project!&#8221;);</p>
<p>Always reuse code rather than cutting and pasting it unless the code is so trivial (say under 10 lines) or would require too much parametrization (say 5+ parameters) to effectively reuse;</p>
<p>Strive to minimize lines of code as best you can;</p>
<p>Don&#8217;t try and do things the Java, C# or Ruby way in PHP. Do things the PHP way. Those other languages each have fundamentally different models;</p>
<p>Never, ever, ever use require_once or include_once. Some will no doubt disagree with this but I see those as being symptomatic of laziness and poor organization. They&#8217;re also slower than require and include and arguably anathema to caching;</p>
<p>Always use opcode caching. This is usually as simple as turning APC on in your php.ini; Use output buffering (ie ob_start(), etc);</p>
<p>Set up common constants, database connections and so on in a file that you include at the top of every one of your scripts; and</p>
<p>Be consistent. I can&#8217;t stress how important that is.</p>
<h2  class="related_post_title">Related Topic</h2><ul class="related_post"><li><a href="http://arisroyo.com/2012/01/20/when-internet-goes-dark-sopa/" title="When Internet Goes Dark [SOPA]">When Internet Goes Dark [SOPA]</a></li><li><a href="http://arisroyo.com/2012/01/12/php-w3schools-certified/" title="PHP w3Schools Certified">PHP w3Schools Certified</a></li><li><a href="http://arisroyo.com/2011/05/06/install-and-configure-lamp-linux-apache-mysql-php/" title="Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]">Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]</a></li><li><a href="http://arisroyo.com/2011/05/05/shop-pay-cash-facebook-apps/" title="Shop &#038; Pay Cash &#8211; Facebook Apps">Shop &#038; Pay Cash &#8211; Facebook Apps</a></li><li><a href="http://arisroyo.com/2011/03/25/php-curl-example/" title="PHP cURL Example">PHP cURL Example</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://arisroyo.com/2011/05/12/php-is-a-templating-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install And Configure LAMP [Linux, Apache, MySql &amp; PHP]</title>
		<link>http://arisroyo.com/2011/05/06/install-and-configure-lamp-linux-apache-mysql-php/</link>
		<comments>http://arisroyo.com/2011/05/06/install-and-configure-lamp-linux-apache-mysql-php/#comments</comments>
		<pubDate>Fri, 06 May 2011 01:00:40 +0000</pubDate>
		<dc:creator>Aris Royo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.arisroyo.com/?p=464</guid>
		<description><![CDATA[Sharing some of my configuration using Linux Trisquel Gnu/Linux free operating software, as a web developer LAMP or Linux Apache MySql and PHP are some of standard application, database and tools that I use in daily programming life. Why Linux? Because it&#8217;s free and makes your laptop or desktop more powerful and advance in computing [...]]]></description>
			<content:encoded><![CDATA[<p>Sharing some of my configuration using Linux Trisquel Gnu/Linux free operating software, as a web developer LAMP or Linux Apache MySql and PHP are some of standard application, database and tools that I use in daily programming life.</p>
<p>Why Linux? Because it&#8217;s free and makes your laptop or desktop more powerful and advance in computing and not like propriety software every tools that you need in development you can get it free and more thing it&#8217;s really cool being free or open source developer.</p>
<p>Linux is your operating system that has a lot of flavor or faces that you can get and download for free, I personally using Trisquel Gnu/Linux that you may download at <a href="http://trisquel.info">http://trisquel.info</a></p>
<p>Now let&#8217;s start installing Apache, you must first login as root or administrator on your Linux machine.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="php"><span class="php-var">$</span> sudo su</span></pre>
</div>
<p>Install in configure apache by calling the following command.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="php"><span class="php-var">$</span> sudo aptitude install apache<span class="php-number">2</span></span></pre>
</div>
<p>The following path and command are some reference you need to know about apache in your machine.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
</pre>
<pre><span class="php"><span class="php-operator">/</span><span class="php-keyword">var</span><span class="php-operator">/</span>ww <span class="php-operator">-</span> Here is your <span class="php-keyword">default</span> document root<span class="php-operator">.</span>
<span class="php-operator">/</span>etc<span class="php-operator">/</span>apache<span class="php-number">2</span><span class="php-operator">/</span>apache<span class="php-number">2</span><span class="php-operator">.</span>conf <span class="php-operator">-</span> Configuration later we need to access this <span class="php-keyword">for</span> some modification<span class="php-operator">.</span>
 <span class="php-operator">/</span>etc<span class="php-operator">/</span>init<span class="php-operator">.</span>d<span class="php-operator">/</span>apache<span class="php-number">2</span> restart This the command to restart the Apache server
 <span class="php-operator">/</span>etc<span class="php-operator">/</span>init<span class="php-operator">.</span>d<span class="php-operator">/</span>apache<span class="php-number">2</span> stop This is the command to stop Apache server
 <span class="php-operator">/</span>etc<span class="php-operator">/</span>init<span class="php-operator">.</span>d<span class="php-operator">/</span>apache<span class="php-number">2</span> start This the command to start it again</span></pre>
</div>
<p>Now to install Mysql execute the command and make sure have properly record the password you provided to mysql database configuration.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="php"><span class="php-var">$</span> sudo aptitude install mysql<span class="php-operator">-</span>server mysql<span class="php-operator">-</span>client</span></pre>
</div>
<p>Last to install the PHP execute the following command</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="php"><span class="php-var">$</span> sudo aptitude install php<span class="php-number">5</span> libapache<span class="php-number">2</span><span class="php-operator">-</span>mod<span class="php-operator">-</span>php<span class="php-number">5</span></span></pre>
</div>
<p>To test the php restart the apache and create the following php script.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
</pre>
<pre><span class="php">Create <span class="php-function">phpinfo</span><span class="php-operator">.</span>php <span class="php-function">file</span> in <span class="php-operator">/</span><span class="php-keyword">var</span><span class="php-operator">/</span>www<span class="php-operator">/</span>
gedit <span class="php-operator">/</span><span class="php-keyword">var</span><span class="php-operator">/</span>www<span class="php-operator">/</span><span class="php-function">phpinfo</span><span class="php-operator">.</span>php
<span class="php-script-tag">&lt;?php</span> <span class="php-function">phpinfo</span><span class="php-brackets">(</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>Test it by calling localhost/phpinfo.php in your browser</p>
<p>No for additional you also like to install phpMyAdmin and Open JDK here the following command.</p>
<p>Installing phpMyadmin</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="php"><span class="php-var">$</span> sudo aptitude install phpmyadmin</span></pre>
</div>
<p>During configuration chose the following option</p>
<ul>
<li>Select apache 2 in Configuring phpMyAdmin</li>
<li>Select No in Configuring database for phpMyAdmin</li>
<li>Edit apache configuration /etc/apache2/apache2.conf by adding the following line-<strong>Include /etc/phpmyadmin/apache.conf</strong>
</li>
</ul>
<p>Installing open-jdk</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
</pre>
<pre><span class="php"><span class="php-var">$</span> aptitude install openjdk<span class="php-operator">-</span><span class="php-number">6</span><span class="php-operator">-</span>jre
<span class="php-var">$</span> aptitude install openjdk<span class="php-operator">-</span><span class="php-number">6</span><span class="php-operator">-</span>jdk</span></pre>
</div>
<p><br/></p>
<h2  class="related_post_title">Related Topic</h2><ul class="related_post"><li><a href="http://arisroyo.com/2012/01/20/when-internet-goes-dark-sopa/" title="When Internet Goes Dark [SOPA]">When Internet Goes Dark [SOPA]</a></li><li><a href="http://arisroyo.com/2012/01/12/php-w3schools-certified/" title="PHP w3Schools Certified">PHP w3Schools Certified</a></li><li><a href="http://arisroyo.com/2011/07/04/avg-free-linux-anti-virus/" title="AVG Free Linux Antivirus">AVG Free Linux Antivirus</a></li><li><a href="http://arisroyo.com/2011/05/12/php-is-a-templating-language/" title="PHP Is A Templating Language">PHP Is A Templating Language</a></li><li><a href="http://arisroyo.com/2011/05/05/shop-pay-cash-facebook-apps/" title="Shop &#038; Pay Cash &#8211; Facebook Apps">Shop &#038; Pay Cash &#8211; Facebook Apps</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://arisroyo.com/2011/05/06/install-and-configure-lamp-linux-apache-mysql-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shop &amp; Pay Cash &#8211; Facebook Apps</title>
		<link>http://arisroyo.com/2011/05/05/shop-pay-cash-facebook-apps/</link>
		<comments>http://arisroyo.com/2011/05/05/shop-pay-cash-facebook-apps/#comments</comments>
		<pubDate>Wed, 04 May 2011 23:00:08 +0000</pubDate>
		<dc:creator>Aris Royo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[cashsense]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.arisroyo.com/?p=458</guid>
		<description><![CDATA[March 2011, when I become a part of development group of cashsense.com, my part is to develop and integrate merchandise item to facebook application page as store, using the new facebook graph API and Java Script. It&#8217;s a wonderful and challenging experience working with developer with cashsense and I&#8217;m happy that I completed the project [...]]]></description>
			<content:encoded><![CDATA[<p>March 2011, when I become a part of development group of cashsense.com, my part is to develop and integrate merchandise item to facebook application page as store, using the new facebook graph API and Java Script.</p>
<p>It&#8217;s a wonderful and challenging experience working with developer with cashsense and I&#8217;m happy that I completed the project in 5 weeks.</p>
<p>Cashsense.com developer continues the enhancement of the application and I&#8217;m glad to see it now working well in facebook world and to see that the number of user&#8217;s is continuing to grow.</p>
<p>The facebook integration is consisting of the following component, facebook graph, facebook java script and off course cashsense API.</p>
<blockquote><p>Cashsense was originally conceived and formed in 2005 as the payment processing division for a multi-national IT development and marketing company based in Manila, Philippines.</p>
<p>Following the successful launch of its Overseas Filipino Workers (OFWs) remittance business, Cashsense continues to develop and launch additional business lines based on technological efficiencies and the straight-through processing of payments; payments made, primarily, by cash. &#8211; <a href="http://www.cashsense.com">www.cashsense.com</a></p></blockquote>
<h2  class="related_post_title">Related Topic</h2><ul class="related_post"><li><a href="http://arisroyo.com/2012/01/20/when-internet-goes-dark-sopa/" title="When Internet Goes Dark [SOPA]">When Internet Goes Dark [SOPA]</a></li><li><a href="http://arisroyo.com/2012/01/12/php-w3schools-certified/" title="PHP w3Schools Certified">PHP w3Schools Certified</a></li><li><a href="http://arisroyo.com/2011/05/12/php-is-a-templating-language/" title="PHP Is A Templating Language">PHP Is A Templating Language</a></li><li><a href="http://arisroyo.com/2011/05/06/install-and-configure-lamp-linux-apache-mysql-php/" title="Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]">Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]</a></li><li><a href="http://arisroyo.com/2011/03/31/please-help-find-catherine-c-romana/" title="Please Help Find Catherine C. Romana">Please Help Find Catherine C. Romana</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://arisroyo.com/2011/05/05/shop-pay-cash-facebook-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP cURL Example</title>
		<link>http://arisroyo.com/2011/03/25/php-curl-example/</link>
		<comments>http://arisroyo.com/2011/03/25/php-curl-example/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 00:00:52 +0000</pubDate>
		<dc:creator>Aris Royo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.arisroyo.com/?p=413</guid>
		<description><![CDATA[The following example is on how to use the PHP cURL request and transform the respond data into simple xml content. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 [...]]]></description>
			<content:encoded><![CDATA[<p>The following example is on how to use the PHP cURL request and transform the respond data into simple xml content.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
</pre>
<pre><span class="php"><span class="php-comment">//construct required data
</span>
<span class="php-var">$data</span>  <span class="php-operator">=</span> <span class="php-string">'UserName='</span><span class="php-operator">.</span><span class="php-var">$userName</span><span class="php-operator">.</span><span class="php-string">'&amp;Password='</span><span class="php-operator">.</span><span class="php-var">$passWord</span><span class="php-operator">.</span><span class="php-string">''</span>;

<span class="php-comment">//build header for request
</span>
<span class="php-var">$headers</span> <span class="php-operator">=</span> <span class="php-keyword">array</span><span class="php-brackets">(</span>
	<span class="php-string">&quot;POST /submit/form.php HTTP/1.1&quot;</span>,
	<span class="php-string">&quot;Host: test.mydomain.com&quot;</span>,
	<span class="php-string">&quot;Content-type: application/x-www-form-urlencoded&quot;</span>,
	<span class="php-string">&quot;Content-length: &quot;</span><span class="php-operator">.</span><span class="php-function">strlen</span><span class="php-brackets">(</span><span class="php-var">$data</span><span class="php-brackets">)</span>
	<span class="php-brackets">)</span>; 

<span class="php-comment">//initialize curl and execute
</span>
<span class="php-var">$ch</span> <span class="php-operator">=</span> <span class="php-function">curl_init</span><span class="php-brackets">(</span><span class="php-brackets">)</span>;
<span class="php-function">curl_setopt</span><span class="php-brackets">(</span><span class="php-var">$ch</span>, CURLOPT_HTTPHEADER,<span class="php-var">$headers</span><span class="php-brackets">)</span>;
<span class="php-function">curl_setopt</span><span class="php-brackets">(</span><span class="php-var">$ch</span>, CURLOPT_URL,
	<span class="php-string">&quot;http://test.mydomain.com/test/submit/form.php&quot;</span><span class="php-brackets">)</span>; <span class="php-comment">// actual url to submit
</span>
<span class="php-function">curl_setopt</span><span class="php-brackets">(</span><span class="php-var">$ch</span>, CURLOPT_POST,<span class="php-number">1</span><span class="php-brackets">)</span>;
<span class="php-comment">//just retrive data don't write
</span>
<span class="php-function">curl_setopt</span><span class="php-brackets">(</span><span class="php-var">$ch</span>, CURLOPT_RETURNTRANSFER,<span class="php-number">1</span><span class="php-brackets">)</span>; 

<span class="php-comment">//provide required data
</span>
<span class="php-function">curl_setopt</span><span class="php-brackets">(</span><span class="php-var">$ch</span>, CURLOPT_POSTFIELDS, <span class="php-var">$data</span><span class="php-brackets">)</span>;
<span class="php-var">$content</span> <span class="php-operator">=</span> <span class="php-function">curl_exec</span><span class="php-brackets">(</span><span class="php-var">$ch</span><span class="php-brackets">)</span>;
<span class="php-function">curl_close</span><span class="php-brackets">(</span><span class="php-var">$ch</span><span class="php-brackets">)</span>;

<span class="php-comment">//tranfer to xml content respond should be xml format too.
</span>
<span class="php-var">$xml</span> <span class="php-operator">=</span> <span class="php-function">simplexml_load_string</span><span class="php-brackets">(</span><span class="php-var">$content</span>,<span class="php-string">'SimpleXMLElement'</span>, LIBXML_NOCDATA<span class="php-brackets">)</span>;</span></pre>
</div>
<p><br/><br />
Reference:<br />
<a href="http://php.net/manual/en/book.curl.php">http://php.net/manual/en/book.curl.php</a></p>
<h2  class="related_post_title">Related Topic</h2><ul class="related_post"><li><a href="http://arisroyo.com/2012/01/20/when-internet-goes-dark-sopa/" title="When Internet Goes Dark [SOPA]">When Internet Goes Dark [SOPA]</a></li><li><a href="http://arisroyo.com/2012/01/12/php-w3schools-certified/" title="PHP w3Schools Certified">PHP w3Schools Certified</a></li><li><a href="http://arisroyo.com/2011/05/12/php-is-a-templating-language/" title="PHP Is A Templating Language">PHP Is A Templating Language</a></li><li><a href="http://arisroyo.com/2011/05/06/install-and-configure-lamp-linux-apache-mysql-php/" title="Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]">Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]</a></li><li><a href="http://arisroyo.com/2011/05/05/shop-pay-cash-facebook-apps/" title="Shop &#038; Pay Cash &#8211; Facebook Apps">Shop &#038; Pay Cash &#8211; Facebook Apps</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://arisroyo.com/2011/03/25/php-curl-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP FTP/SFTP Function</title>
		<link>http://arisroyo.com/2011/03/21/php-ftpsftp-function/</link>
		<comments>http://arisroyo.com/2011/03/21/php-ftpsftp-function/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 23:00:15 +0000</pubDate>
		<dc:creator>Aris Royo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SFTP]]></category>

		<guid isPermaLink="false">http://blog.arisroyo.com/?p=404</guid>
		<description><![CDATA[Sharing the two powerful PHP file transfer function using FTP and SFTP. FTP 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 [...]]]></description>
			<content:encoded><![CDATA[<p>Sharing the two powerful PHP file transfer function using FTP and SFTP.</p>
<p><strong>FTP</strong></p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
</pre>
<pre><span class="php"><span class="php-function">function</span> ftpUpload<span class="php-brackets">(</span><span class="php-var">$ftp_host</span>, <span class="php-var">$ftp_username</span>, <span class="php-var">$ftp_password</span>, <span class="php-var">$ftp_path</span>, <span class="php-var">$filename</span><span class="php-brackets">)</span> <span class="php-brackets">{</span>

	<span class="php-comment">//Connect to FTP host
</span>
	<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-var">$ftp</span> <span class="php-operator">=</span> <span class="php-function">ftp_connect</span><span class="php-brackets">(</span><span class="php-var">$ftp_host</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-brackets">{</span>
		<span class="php-function">die</span> <span class="php-brackets">(</span><span class="php-string">'Unable to connect to the specified FTP.'</span><span class="php-brackets">)</span>;
	<span class="php-brackets">}</span>

	<span class="php-comment">//Login to FTP
</span>
	<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-var">$ftp</span>, <span class="php-var">$ftp_username</span>, <span class="php-var">$ftp_password</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-brackets">{</span>
		<span class="php-function">die</span> <span class="php-brackets">(</span><span class="php-string">'Unable to login to the FTP Server.'</span><span class="php-brackets">)</span>;
	<span class="php-brackets">}</span>

	<span class="php-comment">//local file name destination or new filename
</span>
	<span class="php-var">$local_filename</span> <span class="php-operator">=</span> <span class="php-var">$filename</span>;

	<span class="php-comment">//Upload file to ftp host.
</span>
	<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-function">ftp_put</span><span class="php-brackets">(</span><span class="php-var">$ftp</span>, <span class="php-var">$filename</span>, <span class="php-var">$local_filename</span>, FTP_ASCII<span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-brackets">{</span>
		<span class="php-function">die</span><span class="php-brackets">(</span><span class="php-string">'Unable to upload file.'</span><span class="php-brackets">)</span>;
	<span class="php-brackets">}</span>

<span class="php-keyword">return</span> TRUE;

<span class="php-brackets">}</span></span></pre>
</div>
<p><br/><br />
<strong>SFTP</strong></p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
</pre>
<pre><span class="php"><span class="php-function">function</span> sftpUpload<span class="php-brackets">(</span><span class="php-var">$ftp_host</span>, <span class="php-var">$ftp_username</span>, <span class="php-var">$ftp_password</span>, <span class="php-var">$ftp_path</span>, <span class="php-var">$filename</span><span class="php-brackets">)</span> <span class="php-brackets">{</span>

	<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-operator">!</span> <span class="php-function">function_exists</span><span class="php-brackets">(</span><span class="php-string">'ssh2_connect'</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-brackets">{</span>
		<span class="php-function">die</span><span class="php-brackets">(</span><span class="php-string">'function is not available.'</span><span class="php-brackets">)</span>;
	<span class="php-brackets">}</span>

	<span class="php-comment">//Connect to SFTP host
</span>
	<span class="php-var">$connection</span> <span class="php-operator">=</span> <span class="php-function">ssh2_connect</span><span class="php-brackets">(</span><span class="php-var">$loc_ftp_host</span>, <span class="php-var">$port</span><span class="php-operator">=</span><span class="php-number">2</span><span class="php-number">2</span><span class="php-brackets">)</span>;
	<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-operator">!</span> <span class="php-var">$connection</span><span class="php-brackets">)</span>
		<span class="php-function">die</span><span class="php-brackets">(</span><span class="php-string">'Could not connect to $ftp_host on port $port.'</span><span class="php-brackets">)</span>;

	<span class="php-comment">//Login to SFTP host
</span>
	<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-operator">!</span> <span class="php-function">ssh2_auth_password</span><span class="php-brackets">(</span><span class="php-var">$connection</span>, <span class="php-var">$loc_ftp_username</span>, <span class="php-var">$loc_ftp_password</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
		<span class="php-function">die</span><span class="php-brackets">(</span><span class="php-string">'Could not authenticate with username and password.'</span><span class="php-brackets">)</span>;

	<span class="php-var">$sftp</span> <span class="php-operator">=</span> <span class="php-function">ssh2_sftp</span><span class="php-brackets">(</span><span class="php-var">$connection</span><span class="php-brackets">)</span>;

	<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-operator">!</span> <span class="php-var">$sftp</span><span class="php-brackets">)</span> <span class="php-function">die</span><span class="php-brackets">(</span><span class="php-string">'Could not initialize sftp subsystem.'</span><span class="php-brackets">)</span>;

	<span class="php-comment">//Create or open file
</span>
	<span class="php-var">$stream</span> <span class="php-operator">=</span> <span class="php-function">fopen</span><span class="php-brackets">(</span><span class="php-string">'ssh2.sftp://'</span><span class="php-operator">.</span><span class="php-var">$sftp</span><span class="php-operator">.</span><span class="php-var">$ftp_path</span><span class="php-operator">.</span><span class="php-string">'/'</span><span class="php-operator">.</span><span class="php-var">$filename</span>, <span class="php-string">'w'</span><span class="php-brackets">)</span>;

	<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-operator">!</span> <span class="php-var">$stream</span><span class="php-brackets">)</span> <span class="php-function">die</span><span class="php-brackets">(</span><span class="php-string">'Could not open file: $filename'</span><span class="php-brackets">)</span>;

	<span class="php-var">$local_filename</span> <span class="php-operator">=</span> <span class="php-var">$filename</span>;

	<span class="php-var">$data_to_send</span> <span class="php-operator">=</span> <span class="php-function">file_get_contents</span><span class="php-brackets">(</span><span class="php-var">$local_filename</span><span class="php-brackets">)</span>;

	<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-var">$data_to_send</span> <span class="php-operator">=</span><span class="php-operator">=</span><span class="php-operator">=</span> <span class="php-keyword">false</span><span class="php-brackets">)</span>
		<span class="php-function">die</span><span class="php-brackets">(</span><span class="php-string">'Could not open local file: $local_filename.'</span><span class="php-brackets">)</span>;

	<span class="php-keyword">if</span> <span class="php-brackets">(</span>@<span class="php-function">fwrite</span><span class="php-brackets">(</span><span class="php-var">$stream</span>, <span class="php-var">$data_to_send</span><span class="php-brackets">)</span> <span class="php-operator">=</span><span class="php-operator">=</span><span class="php-operator">=</span> <span class="php-keyword">false</span><span class="php-brackets">)</span>
	    <span class="php-function">die</span><span class="php-brackets">(</span><span class="php-string">'Could not send data from file: $local_filename.'</span><span class="php-brackets">)</span>;

	@<span class="php-function">fclose</span><span class="php-brackets">(</span><span class="php-var">$stream</span><span class="php-brackets">)</span>;

	<span class="php-keyword">return</span> TRUE;

<span class="php-brackets">}</span></span></pre>
</div>
<p><br/><br />
Reference:<br />
FTP Manual &#8211; <a href="http://php.net/manual/en/book.ftp.php">http://php.net/manual/en/book.ftp.php</a><br />
SFTP Manual &#8211; <a href="http://www.php.net/manual/en/ref.ssh2.php">http://www.php.net/manual/en/ref.ssh2.php</a></p>
<h2  class="related_post_title">Related Topic</h2><ul class="related_post"><li><a href="http://arisroyo.com/2012/01/20/when-internet-goes-dark-sopa/" title="When Internet Goes Dark [SOPA]">When Internet Goes Dark [SOPA]</a></li><li><a href="http://arisroyo.com/2012/01/12/php-w3schools-certified/" title="PHP w3Schools Certified">PHP w3Schools Certified</a></li><li><a href="http://arisroyo.com/2011/05/12/php-is-a-templating-language/" title="PHP Is A Templating Language">PHP Is A Templating Language</a></li><li><a href="http://arisroyo.com/2011/05/06/install-and-configure-lamp-linux-apache-mysql-php/" title="Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]">Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]</a></li><li><a href="http://arisroyo.com/2011/05/05/shop-pay-cash-facebook-apps/" title="Shop &#038; Pay Cash &#8211; Facebook Apps">Shop &#038; Pay Cash &#8211; Facebook Apps</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://arisroyo.com/2011/03/21/php-ftpsftp-function/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Do I really need a PHP framework?</title>
		<link>http://arisroyo.com/2010/02/24/do-i-really-need-a-php-framework/</link>
		<comments>http://arisroyo.com/2010/02/24/do-i-really-need-a-php-framework/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 00:00:47 +0000</pubDate>
		<dc:creator>Aris Royo</dc:creator>
				<category><![CDATA[Tech Life]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programing]]></category>

		<guid isPermaLink="false">http://www.arisroyo.com/?p=126</guid>
		<description><![CDATA[Two weeks ago when I start searching for PHP framework that I can use for my web project development, I landed to a three different framework witch CakePHP, CodeIgniter and DooPHP both of them promise different features, quick development where you’re going to be excited. In the long run of review and testing of these [...]]]></description>
			<content:encoded><![CDATA[<p>Two weeks ago when I start searching for PHP framework that I can use for my web project development, I landed to a three different framework witch CakePHP, CodeIgniter and DooPHP both of them promise different features, quick development where you’re going to be excited.</p>
<p>In the long run of review and testing of these three PHP framework, I started to ask some question like &#8220;Do I really need a framework&#8221; I landed to a different blog and forum to answer my quest.</p>
<p>1.Do I really need a PHP framework?<br />
2.Its PHP framework can handle out of the box programming needs and all business requirements?</p>
<p>All though it&#8217;s a long debate and programmer has different point of view I decide to list down the pros and cons of using PHP framework and its advantage and disadvantage.</p>
<p>Advantage of Using Framework</p>
<ul>
<li>You don&#8217;t even have to write OO code if you don&#8217;t want to.</li>
<li>Provide a solid structure for your code.</li>
<li>Extra functionality that would be much harder to replicate on its own.</li>
<li>MVC Structured code (Model-View-Container ).</li>
<li>Enforcing of good coding standards.</li>
<li>Pretty URLS.</li>
<li>Less time coding.</li>
</ul>
<p>Disadvantage of Using Framework</p>
<ul>
<li>Hide the original syntax of PHP</li>
<li>Slower then a simple php.</li>
<li>It&#8217;s heavy, more compiling time</li>
<li>Framework is like third party software</li>
<li>Limited resources &amp; support</li>
<li>Framework is for weak Programmer</li>
</ul>
<p>My Conclusion</p>
<p>For small project use custom PHP toolkit is good, for big project I suggest to carefully review and decide if you going to use framework. Instead of reading its feature and promise go to forum and read all the issued raised so you can get an idea of what possible problem that you may encounter.</p>
<p>If your PHP project will handle out of the box programming needs and ideas, I suggest don&#8217;t use framework rather than use framework, design carefully your project needs and develop a clean and secure object oriented code.</p>
<p>Because framework are built in solution for your project needs it&#8217;s doesn&#8217;t mean It can handle all possible business and project requirements.</p>
<p>Remember that framework is also made from programming native language, I don&#8217;t want to say to create you own framework but of course you can design framework for you own project specific needs, it will help you become more strong in programming analysis and design.</p>
<p>Remember that you can also design your project with Pretty URL and implement standard coding in the team.</p>
<p>Relying on framework will only make you idle and dependent on framework, I remember the time when one of my teams mate approach me and said that his group can&#8217;t proceed to their task because there is no available library for their needs, they found one framework witch is limited in function and feature. My answer to him is very simple &#8220;Then crate your own library or framework&#8221;.</p>
<blockquote><p>But overall it&#8217;s still depend on your needs and what generation programming language you are in.</p></blockquote>
<h2  class="related_post_title">Related Topic</h2><ul class="related_post"><li><a href="http://arisroyo.com/2012/01/20/when-internet-goes-dark-sopa/" title="When Internet Goes Dark [SOPA]">When Internet Goes Dark [SOPA]</a></li><li><a href="http://arisroyo.com/2012/01/12/php-w3schools-certified/" title="PHP w3Schools Certified">PHP w3Schools Certified</a></li><li><a href="http://arisroyo.com/2011/05/12/php-is-a-templating-language/" title="PHP Is A Templating Language">PHP Is A Templating Language</a></li><li><a href="http://arisroyo.com/2011/05/06/install-and-configure-lamp-linux-apache-mysql-php/" title="Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]">Install And Configure LAMP [Linux, Apache, MySql &#038; PHP]</a></li><li><a href="http://arisroyo.com/2011/05/05/shop-pay-cash-facebook-apps/" title="Shop &#038; Pay Cash &#8211; Facebook Apps">Shop &#038; Pay Cash &#8211; Facebook Apps</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://arisroyo.com/2010/02/24/do-i-really-need-a-php-framework/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

