<?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>Bin-Blog &#187; PHP</title>
	<atom:link href="http://www.bin-co.com/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bin-co.com/blog</link>
	<description>Learn about the latest in Web Development - as soon as I do.</description>
	<lastBuildDate>Tue, 13 Oct 2009 18:55:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Installing lighttpd Web Server in Linux with PHP and MySQL</title>
		<link>http://www.bin-co.com/blog/2008/11/installing-lighttpd-web-server-in-linux-with-php-and-mysql/</link>
		<comments>http://www.bin-co.com/blog/2008/11/installing-lighttpd-web-server-in-linux-with-php-and-mysql/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 17:48:21 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=161</guid>
		<description><![CDATA[After <a href="http://www.bin-co.com/blog/2008/09/installing-lampapache-web-serverphpmysql-in-debian/" title="Installing LAMP(Apache Web Server/PHP/MySQL) in Debian">two articles</a> on <a href="http://www.bin-co.com/blog/2008/09/compile-install-lamp-linux-apache-mysql-php-server-from-source/" title="Compile and Install a LAMP(Linux/Apache/MySQL/PHP) Server from Source">installing Apache</a>, lets take a look at <strong class="highlight">installing and configuring lighttpd web server on a linux system</strong>. <a href="http://www.lighttpd.net/">lighttpd</a> (pronounced "lighty") is a web server designed to be secure, fast, standards-compliant and flexible while having a low memory footprint.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/11/lighttpd_logo.png" alt="lighttpd Web Server" title="Lighttpd Logo" width="200" height="197" class="alignnone size-full wp-image-160 intro" align="right" /></p>
<p class="intro">After <a href="http://www.bin-co.com/blog/2008/09/installing-lampapache-web-serverphpmysql-in-debian/" title="Installing LAMP(Apache Web Server/PHP/MySQL) in Debian">two articles</a> on <a href="http://www.bin-co.com/blog/2008/09/compile-install-lamp-linux-apache-mysql-php-server-from-source/" title="Compile and Install a LAMP(Linux/Apache/MySQL/PHP) Server from Source">installing Apache</a>, lets take a look at <strong class="highlight">installing and configuring lighttpd web server on a linux system</strong>. <a href="http://www.lighttpd.net/">lighttpd</a> (pronounced &#8220;lighty&#8221;) is a web server designed to be secure, fast, standards-compliant and flexible while having a low memory footprint.</p>
<p>Before installation, a few points to remember. These <strong class="highlight">instruction are not for a production environment &#8211; this is for a development environment</strong>. To install the software, <strong class="highlight">you need root access</strong>. You can get that using this command&#8230;</p>
<pre><code class="cli">su -
[Enter root password]</code></pre>
<p>or by prefixing &#8216;<code>sudo</code>&#8216; before each command.</p>
<h2>Installing the Server</h2>
<p>First install lighttpd and PHP &#8211; use your distro&#8217;s package management(yum, apt-get) system to do this.</p>
<h3>Install lighttpd</h3>
<p>You can use this command in Red Hat based systems(Fedora, Cent OS, etc.) to install lighttpd. Debian/Ubuntu systems might the same package name &#8211; could someone post the package name of lighttpd in the comments?</p>
<pre><code class="cli">yum install lighttpd lighttpd-fastcgi</code></pre>
<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/09/php-logo.png" alt="PHP Logo" title="PHP Logo" width="179" height="98" class="alignnone size-full wp-image-123" align="right" /></p>
<h3>Install PHP</h3>
<p>If you don&#8217;t have PHP, you can install it using the command&#8230;</p>
<pre><code class="cli">yum install php php-cli php-common</code></pre>
<p>In Debian/Ubuntu systems, the command is&#8230;</p>
<pre><code class="cli">apt-get install php5-cli php5-common php5-cgi</code></pre>
<p>You can make sure you have php-cgi(needed for working with lighttpd) by running this command&#8230;</p>
<pre><code class="cli">php-cgi -v</code></pre>
<h3>Installing MySQL</h3>
<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/09/mysql_logo.gif" alt="" title="MySQL Logo" width="150" height="98" class="alignnone size-full wp-image-127" align="right" /></p>
<p>If MySQL is not yet installed, use this command to install it&#8230;</p>
<pre><code class="cli">yum install mysql-server php-mysql mysql mysql-libs</code></pre>
<p>Debian/Ubuntu Command&#8230;</p>
<pre><code class="cli">apt-get install mysql-client mysql-common mysql-server php5-mysql</code></pre>
<h2>Configuring lighttpd</h2>
<p>lighttpd configuration is done by <strong class="highlight">editing the text file &#8216;/etc/lighttpd/lighttpd.conf&#8217;.</strong></p>
<p><strong class="highlight">Enable some lighttpd modules</strong> by removing the comment character(#) from the beginning of the line. I have enabled the following modules&#8230;</p>
<pre><code class="conf">server.modules              = (
                                "mod_rewrite",
                                "mod_redirect",
                                "mod_access",
                                "mod_fastcgi",
                                "mod_accesslog" )
</code></pre>
<p><strong class="highlight">Configure lighttpd&#8217;s document root</strong> &#8211; if you already have Apache, I would recommend using the same document root as Apache(applicable for development servers only). </p>
<pre><code class="conf">server.document-root        = "/var/www/"</code></pre>
<p>I find it helpful to <strong class="highlight">enable folder listing</strong> in my server.</p>
<pre><code class="conf">## virtual directory listings
dir-listing.activate       = "enable"</code></pre>
<h3>Turn On FastCGI PHP Support</h3>
<p>Now, make sure lighttpd works with PHP &#8211; first get the path of php-cgi using the command..</p>
<pre><code class="cli">$ whereis php-cgi
php-cgi: /usr/bin/php-cgi #Might be different on your system.</code></pre>
<p>Then <strong class="highlight">add the path to the configuration file</strong> of lighttpd&#8230;</p>
<pre><code class="conf">#### fastcgi module
## read fastcgi.txt for more info
## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini
fastcgi.server             = ( ".php" =>
                               ( "localhost" =>
                                 (
                                   "socket" => "/tmp/php.socket",
                                   <strong class="highlight">"bin-path" => "/usr/bin/php-cgi"</strong>
                                 )
                               )
                            )</code></pre>
<p>Make sure you <strong class="highlight">uncomment the above lines</strong> by removing the &#8216;#&#8217; characters.</p>
<p>After you are done, <strong class="highlight">save the file</strong>. Time to try out the server.</p>
<h2>Starting the lighttpd Server</h2>
<p>First stop Apache if it is running&#8230;</p>
<pre><code class="cli">/etc/init.d/httpd stop</code></pre>
<p>Now start lighttpd using the command</p>
<pre><code class="cli">/etc/init.d/lighttpd start</code></pre>
<p>Go to your document root(<code>/var/www</code>) and <strong class="highlight">create a php files called &#8216;info.php&#8217; and put this code</strong> inside it&#8230;</p>
<pre><code class="php">&lt;?php
php<!-- wordpress bug workaround -->Info();</code></pre>
<p>Now fire up a browser and <strong class="highlight">go to <a href="http://localhost/" title="Might not work if the preceding instructions where not followed">localhost</a></strong> &#8211; you should see a file listing page with a ‘info.php’ in the list. Click on that link &#8211; if you see a PHP information page, your web server is setup correctly.</p>
<p>To make sure MySQL-PHP connection is working, <a href="http://www.bin-co.com/database/clients/phpmyadmin/installing_phpmyadmin.php" title="Installing phpMyAdmin 2.8">install phpMyAdmin</a> &#8211; or write a database connection script &#8211; whatever is easier for you.</p>
<h2>Related Links</h2>
<ul>
<li><a href="http://www.lighttpd.net/">lighttpd fly light</a></li>
<li><a href="http://en.wikipedia.org/wiki/Lighttpd">lighttpd &#8211; Wikipedia</a></li>
<li><a href="http://cssgallery.info/lighttpd-install-perl-mysql-support-in-chrooted-jail/">Lighttpd install perl, mysql support in chrooted jail</a></li>
<li><a href="http://www.cyberciti.biz/tips/lighttpd-php-fastcgi-configuration.html">Lighttpd PHP fastcgi configuration</a></li>
<li><a href="http://www.cyberciti.biz/tips/howto-install-lighttpd-on-freebsd.html">FreeBSD Install Lighttpd Web Server</a></li>
<li><a href="http://fandar-it.com/content/view/35/32/">Install lighttpd with php</a></li>
<li><a href="http://wiki.vpslink.com/Install_and_Configure_lighttpd">Install and Configure lighttpd</a></li>
<li><a href="http://www.howtoforge.com/lighttpd_php5_mysql_fedora7">Installing Lighttpd With PHP5 And MySQL Support On Fedora 7</a></li>
</ul>
<p><strong class="highlight">Shameless Plug</strong>: If you are a Linux user, you may want to check out my <a href="http://lindesk.com/" title="Lindesk - Linux on the Desktop">Linux Blog &#8211; LinDesk</a> &#8211; its about Linux on the Desktop &#8211; Articles, Application Reviews and Tutorials about many aspects of Linux included configuration and scripting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/11/installing-lighttpd-web-server-in-linux-with-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Remote Database Backup WordPress Plugin</title>
		<link>http://www.bin-co.com/blog/2008/10/remote-database-backup-wordpress-plugin/</link>
		<comments>http://www.bin-co.com/blog/2008/10/remote-database-backup-wordpress-plugin/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 16:43:10 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=135</guid>
		<description><![CDATA[My second WordPress Plugin - <a href="http://www.bin-co.com/tools/wordpress/plugins/db_backup/">Remote Database Backup</a>. Its is based on the <a href="http://www.ilfilosofo.com/blog/wp-db-backup">WordPress Database Backup plugin</a>. If you are a regular wordpress user, you might be better off using WordPress Database Backup plugin instead of my version. But if you, like me, have a local server on your system and has a copy of your site on the local server as well as the online server, you will find great use for my plugin.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/10/wordpress_logo.png" alt="" title="Wordpress Logo" width="183" height="145" class="alignnone size-full wp-image-136 intro" align="right" /></p>
<p class="intro">I have released my second WordPress Plugin &#8211; <a href="http://www.bin-co.com/tools/wordpress/plugins/db_backup/">Remote Database Backup</a>. Its is based on the <a href="http://www.ilfilosofo.com/blog/wp-db-backup">WordPress Database Backup plugin</a>. If you are a regular wordpress user, you might be better off using WordPress Database Backup plugin instead of my version. But if you, like me, have a local server on your system and has a copy of your site on the local server as well as the online server, you will find great use for my plugin.</p>
<p>My plugin is designed to make it possible to remotely create and download wordpress database backup in form of SQL dumps. You can then use these dumps to sync the local version of your site with the online version.</p>
<p><img src="http://www.bin-co.com/tools/wordpress/plugins/db_backup/db_backup.png" alt="Remote Database Backup Screenshot" /></p>
<h2>Backuping your WordPress Database</h2>
<ul>
<li>Install Remote Database Backup Plugin in WordPress</li>
<li>Login to WordPress site</li>
<li>Go to the Backup Page(Manage &gt; DB Backup)</li>
<li>Create a backup</li>
<li>Download the backup file to your system</li>
</ul>
<h3>Sync With Local Server</h3>
<p>And if you have a local version of your site, you can sync it with the online site using the backup file. Just follow these steps&#8230;</p>
<ul>
<li>Extract the backup file(its in the tar.gz format)</li>
<li><a href="http://txt.binnyva.com/2007/03/mysql-database-backuprestore/">Import it into your mysql database</a>.</li>
<li>Make some changes to the database(like set the home url) so that wordpress works locally</li>
</ul>
<h2>Automation Script</h2>
<p>You can do all these steps manually &#8211; or you can use the <a href="http://www.bin-co.com/blog/wp-content/uploads/2008/10/backup.txt">automation script</a> I have cooked up. You need PHP installed in your system for this to work(I assume you already have PHP if you have a local version of wordpress).</p>
<p>To use the script, first install the plugin. Then download <a href="http://www.bin-co.com/blog/wp-content/uploads/2008/10/backup.txt">the script</a> and rename it to &#8216;backup.php&#8217;(the extension must be &#8216;php&#8217; instead of &#8216;txt&#8217;. Now open it in your favorite editor and change the variables to match your site. You can run it by opening a terminal/command prompt and navigating to that folder and executing the command &#8216;php backup.php&#8217;. This will automatically make a backup and sync it with your local database.</p>
<h2>Need Feedback</h2>
<p>Let me know how it works for you if you are installing the plugin &#8211; its the first release &#8211; so I need some feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/10/remote-database-backup-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Installing LAMP(Apache Web Server/PHP/MySQL) in Debian/Ubuntu</title>
		<link>http://www.bin-co.com/blog/2008/09/installing-lampapache-web-serverphpmysql-in-debian/</link>
		<comments>http://www.bin-co.com/blog/2008/09/installing-lampapache-web-serverphpmysql-in-debian/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 19:10:07 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=125</guid>
		<description><![CDATA[Installing the <abbr title="Linux Apache MySQL PHP">LAMP</abbr> environment on a Linux system is easy if you are comfortable with using the native package management software. If you on a Red Hat/Fedora/CentOS system, that will be yum - and for Debian/Ubuntu systems, that will be apt. This tutorial shows you how to install Apache 2, PHP 5 and MySQL 5 in Debian using apt.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/09/lava_lamp.jpg" alt="LAMP - Linux, Apache, MySQL, PHP" title="Lamp" width="232" height="294" class="size-full wp-image-128 intro" align="right" /></p>
<p class="intro">Installing the <abbr title="Linux Apache MySQL PHP">LAMP</abbr> environment on a Linux system is easy if you are comfortable with using the native package management software. If you on a Red Hat/Fedora/CentOS system, that will be yum &#8211; and for Debian/Ubuntu systems, that will be apt. This tutorial shows you how to install Apache 2, PHP 5 and MySQL 5 in Debian using apt.</p>
<p>Before installation, a few points to remember. These instruction are not for a production environment &#8211; this is for a development environment. To install the software, you need root access. You can get that using this command&#8230;</p>
<pre><code class="cli">su -
[Enter root password]</code></pre>
<h2>Installing Apache 2</h2>
<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/09/apache.png" alt="" title="Apache Logo" width="230" height="90" class="alignnone size-full wp-image-126" align="right" /></p>
<p>Use this command to install Apache 2.</p>
<pre><code class="javascript">apt-get install apache2</code></pre>
<p>Make sure you specify &#8216;apache2&#8242; &#8211; or else, apache 1.3 will be installed.</p>
<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/09/php-logo.png" alt="PHP Logo" title="PHP Logo" width="179" height="98" class="alignnone size-full wp-image-123" align="right" /></p>
<h2>Install PHP 5</h2>
<p>Now, install the PHP 5 packages&#8230;</p>
<pre><code class="javascript">apt-get install libapache2-mod-php5 php5-cli php5-common php5-cgi</code></pre>
<p>No go to the folder <code>/etc/apache2/sites-enabled/</code> and edit the file in that directory(usually 000-default). Find the line that says<br />
<code>RedirectMatch ^/$ /apache2-default/</code><br />
and remove it.</p>
<p>Now your document root is <code>/var/www/</code> &#8211; place all your HTML documents and scripts in this folder. If you want to make some other configuration changes, edit the configuration files at <code>/etc/apache2/apache2.conf</code></p>
<p>I also had to make the following changes&#8230;</p>
<ul>
<li>Changed the owner of <code>/var/log/apache2</code> to www-data &#8211; I used the command <code>chown www-data:www-data apache2</code></li>
<li>Created an empty file at <code>/etc/apache2/httpd.conf</code></li>
</ul>
<p>This was to fix a few errors I saw on my system &#8211; you may not have to do it.</p>
<h2>Install MySQL</h2>
<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/09/mysql_logo.gif" alt="" title="MySQL Logo" width="150" height="98" class="alignnone size-full wp-image-127" align="right" /></p>
<p>This is the command to install MySQL server, its client and PHP&#8217;s MySQL libraries&#8230;</p>
<pre><code class="javascript">apt-get install mysql-client mysql-common mysql-server php5-mysql</code></pre>
<p>Finally, Install the other packages you need as well</p>
<pre><code class="javascript">apt-get install php5-sqlite php5-gd ...</code></pre>
<h2>Testing the System</h2>
<p>Go to your document root(<code>/var/www</code>) and create a php files called &#8216;info.php&#8217; and put this code inside that&#8230;</p>
<pre><code class="php">&lt;?php
php<!-- PHP bug -->info();

</code></pre>
<h3>Start the Servers</h3>
<p>First, turn on the MySQL database server&#8230;</p>
<pre><code class="javascript">/etc/init.d/mysql start</code></pre>
<p>Then, start the Apache Web Server&#8230;</p>
<pre><code class="javascript">/etc/init.d/apache2 start</code></pre>
<p>Now fire up a browser and go to <a href="http://localhost/">localhost</a> &#8211; you should see a file listing page with a &#8216;info.php&#8217; in the list. Click on that link &#8211; if you see a PHP information page, your web server is setup correctly.</p>
<p>To make sure MySQL-PHP connection is working, <a href="http://www.bin-co.com/database/clients/phpmyadmin/installing_phpmyadmin.php">install phpMyAdmin</a> &#8211; or write a database connection script &#8211; whatever is easier for you.</p>
<h2>Related Links</h2>
<ul>
<li><a href="http://www.thegeekstuff.com/2008/09/how-to-install-or-upgrade-lamp-apache-mysql-and-php-stack-on-linux-using-yum/">How To Install Or Upgrade LAMP: Linux, Apache, MySQL and PHP Stack Using Yum</a></li>
<li><a href="http://www.debianadmin.com/apache2-installation-and-configuration-with-php-support-in-debian-linux.html">Apache2 installation and configuration with php support</a></li>
<li><a href="http://www.debianadmin.com/install-and-configure-apache2-with-php5-and-ssl-support-in-debian-etch.html">Install and Configure Apache2 with PHP5 and SSL Support in Debian Etch</a></li>
<li><a href="http://www.adobe.com/devnet/dreamweaver/articles/lamp.html">Setting Up Your PHP Server Environment Using Linux, Apache, MySQL, and PHP</a></li>
<li><a href="http://www.mysql-apache-php.com/">Quick Linux Server w/ Apache+PHP+MySQL</a></li>
<li><a href="http://www.debianhelp.co.uk/lamp.htm">LAMP (Linux Apache Mysql PHP) Configuration and Installing in Debian</a></li>
<li><a href="http://lamphowto.com/">HOWTO: Installing MySQL and Apache with PHP support on Linux</a></li>
<li><a href="http://www.kewanshunn.com/articles/how_to_install_apache2,_php5,_mysql5_on_redhat/3.html">How to install Apache2, PHP5, MySQL5 on RedHat</a></li>
</ul>
<p><strong>Shameless Plug</strong>: If you are a Linux user, you may want to check out my <a href="http://lindesk.com/">Linux Blog &#8211; LinDesk</a> &#8211; its about Linux on the Desktop &#8211; Articles, Application Reviews and Tutorials about many aspects of Linux included configuration and scripting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/09/installing-lampapache-web-serverphpmysql-in-debian/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Python Reference Manual has a lot to Learn From PHP</title>
		<link>http://www.bin-co.com/blog/2008/06/python-reference-manual-has-a-lot-to-learn-from-php/</link>
		<comments>http://www.bin-co.com/blog/2008/06/python-reference-manual-has-a-lot-to-learn-from-php/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 18:34:49 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[manual]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[reference]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=110</guid>
		<description><![CDATA[Unlike the other scripting languages I work with(like PHP, Ruby, JavaScript, etc.), I am not comfortable using Python. I have made some stuff in Python(for example, frees) &#8211; but I could get into the flow as easily as with other languages. For the longest time, I thought it was because of the whitespace issue. But [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/03/python-logo.gif" alt="" title="Python Logo" width="211" height="71" class="alignnone wp-image-97 intro" align="right"  /></p>
<p class="intro">Unlike the other scripting languages I work with(like PHP, Ruby, JavaScript, etc.), I am not comfortable using Python. I have made some stuff in Python(for example, <a href="http://lindesk.com/2008/04/frees-hard-disk-drives-free-space-viewer/">frees</a>) &#8211; but I could get into the flow as easily as with other languages. For the longest time, I thought it was because of the whitespace issue. But recently, I created a small Python script &#8211; that&#8217;s when I understood that whitespace does not concern me. <strong class="highlight">What make me angry at python is its documentation/manual</strong>.</p>
<p>By Python Manual, I mean the official Python Manual available at <a href="http://docs.python.org/">http://docs.python.org/</a>. I have <strong class="highlight">downloaded the entire <a href="http://www.python.org/doc/2.5.2/download/">manual to my system as HTML files</a> and use that as a reference</strong> when working with Python. This is what I have done for all the other languages I work with&#8230;</p>
<ul>
<li><a href="http://perldoc.perl.org/">Perl</a></li>
<li><a href="http://www.php.net/manual/en/">PHP</a></li>
<li><a href="http://www.ruby-doc.org/docs/ProgrammingRuby/">Ruby</a></li>
<li><a href="http://docs.sun.com/source/816-6408-10/">JavaScript</a> </li>
<li><a href="http://www.w3.org/TR/REC-CSS2/">CSS</a></li>
<li>etc.</li>
</ul>
<h2>Finding a Function</h2>
<p>There is one big problem with using HTML files as your reference &#8211; you cannot search through it. So I try to find a page in the documentation that <strong class="highlight">lists all the functions in a single page</strong>. When I need to find a function, all I have to do is <strong class="highlight">search through this page</strong>. These pages in the documentation serves this purpose&#8230;</p>
<ul>
<li><a href="http://www.php.net/manual/en/indexes.php">PHP</a></li>
<li><a href="http://perldoc.perl.org/index-functions.html">Perl</a></li>
<li><a href="http://docs.sun.com/source/816-6408-10/bklast.htm">JavaScript</a></li>
<li><a href="http://www.ruby-doc.org/docs/ProgrammingRuby/html/builtins.html">Ruby</a></li>
</ul>
<p>What about Python? Well, <strong class="highlight">Python don&#8217;t have such a page</strong> in their manual. The nearest one I could find a combination of four pages &#8211; <a href="http://docs.python.org/modindex.html">Module Index</a> + <a href="http://docs.python.org/lib/genindex.html">Library Index</a> + <a href="http://docs.python.org/tut/node19.html">Tutorial Index</a> + <a href="http://docs.python.org/ref/genindex.html">Language Index</a>. Its no where near as useful.</p>
<p>Even if you are online(remember, many people are not connected all the time), its still <strong class="highlight">not easy to find a function in Python documentation &#8211; even with searching</strong> capabilities. Don&#8217;t believe me? OK &#8211; go to <a href="http://docs.python.org/">Python Docs</a> and try to find the documentation for the function that, say, reverses an array. Now go to the <a href="http://php.net/manual/en/">PHP site</a> and do the same.</p>
<h2>Reference Formats</h2>
<p>Anyway, I cannot really complain about the the availability of the &#8216;function page&#8217;. Its just the way I prefer &#8211; other people may not want such a page. But I can complain about the fact that <strong class="highlight">they don&#8217;t provide a CHM file</strong> in their <a href="http://www.python.org/doc/2.5.2/download/">downloads section</a>. CHM solves the problem as you can search through them easily.</p>
<p>PHP, on other hand, <a href="http://www.php.net/download-docs.php">provides the CHM file</a>. This makes the PHP manual much more easier to use.</p>
<p>Even though Python don&#8217;t officially provide a CHM file, others have made it available on the net. Its just a <a href="http://www.google.com/q=python+reference+chm">google search away</a>. But I prefer to get these stuff from an official source.</p>
<h2>Level of Detail in the Documentation</h2>
<p>The worst sin of the Python manual is that the <strong class="highlight">documentation is not detailed enough</strong>. To better understand this, let&#8217;s take an example &#8211; say the array reversal function. First we take a look at the Python <a href="http://docs.python.org/lib/module-array.html#l2h-779">documentation for this function</a>&#8230;</p>
<dl>
<dt>reverse()</dt>
<dd>Reverse the order of the items in the array.</dd>
</dl>
<p>One line. That&#8217;s it! If you are not well versed in Python, you will have no idea of how to use this function &#8211; because there is no example. Most people will expect that the array must be given as the argument. But the argument list is empty in the documentation. That&#8217;s because the array is not passed as an argument &#8211; rather, in Python, this function is a member function of the array object &#8211; so the proper usage will be something like this&#8230;</p>
<pre><code class="python">x = [1,2,4]
x.reverse()
#Now x has the value [4,2,1]</code></pre>
<p>I know that because I know Python &#8211; but if a new user manages to find the documentation for this function, he will be confused. Another thing &#8211; I am not saying that there are no examples in the documentation &#8211; examples are given for a lot of functions. But its no where near the level that PHP has achieved.</p>
<p>OK &#8211; now lets see the PHP manual for the same function &#8211; <a href="http://php.net/manual/en/function.array-reverse.php">array_reverse()</a>. There is an entire page for that function. Not just for this function &#8211; there is <strong class="highlight">one page of documentation for every function</strong> in PHP. And <strong class="highlight">there are examples</strong>. And at the end, <strong class="highlight">there is a collection of &#8216;user notes&#8217;</strong> &#8211; making each function much clearer. Beautiful!</p>
<p>I feel a bit guilty about comparing Python with PHP documentation &#8211; <strong class="highlight">PHP has the best documentation in its class</strong> of languages. But still, Python has a lot to learn from PHP(I wanted to say that for a long time <img src='http://www.bin-co.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/06/python-reference-manual-has-a-lot-to-learn-from-php/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Hello Script for PHP</title>
		<link>http://www.bin-co.com/blog/2008/03/hello-script-for-php/</link>
		<comments>http://www.bin-co.com/blog/2008/03/hello-script-for-php/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 17:44:25 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/03/hello-script-for-php/</guid>
		<description><![CDATA[In the last post I introduced the concept of &#8216;Hello Script&#8217; &#8211; a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language. I thought I can elaborate on that concept by creating Hello Scripts for all the [...]]]></description>
			<content:encoded><![CDATA[<p class="intro">In the last post I introduced the concept of <strong>&#8216;Hello Script&#8217; &#8211; a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language. I thought I can elaborate on that concept by creating Hello Scripts for all the languages that I am familiar with.</p>
<p>Let&#8217;s start with PHP &#8211; I already provided this as an example for the last post. Here is the entire PHP Hello Script&#8230;</p>
<pre><code class="php">
&lt;?php
// Printing(IO)
print "Hello World!\n";

// Variables, concatenation
$name = 'Binny';
$year = 2008;
print "Hello, " . $name . " - welcome to " . $year . "\n";

//If,else conditions
if ($year &gt; 2008) {
	print "Welcome to the future - yes, we have flying cars!";
}
else if($year &lt; 2008) {
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!";
}
else {
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo.";
}
print "\n";

// For loop
for($i=0; $i&lt;3; $i++) {
	print "$i) Hi there!\n";
}

//Numerical Array, While
$rules = array(
	'Do no harm',
	'Obey',
	'Continue Living'
);
$i = 0;
while($i&lt;count($rules)) {
	print "Rule " . ($i+1) . " : " . $rules[$i] . "\n";
	$i++;
}

// Associated array, foreach
$associated = array(
	'hello'	=&gt;	'world',
	'foo'	=&gt;	'bar',
	'lorem'	=&gt;	'ipsum'
);
foreach($associated as $key =&gt; $value) {
	print "$key: $value\n";
}

// Using Join and Split
$csv_values = explode(',', "hello,world,how,are,you\n");
print implode(":", $csv_values);

// Function, argument, return, call
function hello($name) {
	return "Hello " . $name;
}
$hello_string = hello("Binny");

// One for the OOP fanboys - Class, members, object and stuff.
class Movie {
	public $name = '';
	public $rating = 0;

	function __construct($name) {
		$this-&gt;name = $name;
		$this-&gt;rateMovie();
	}
	function rateMovie() {
		$this-&gt;rating = (strlen($this-&gt;name) % 10) + 1; //IMDBs rating algorithm. True story!
	}

	function printMovieDetails() {
		print "Movie : {$this-&gt;name}\n";
		print "Rating : " . str_repeat('*', $this-&gt;rating) . "({$this-&gt;rating})\n\n";
	}
}
//Create the object
$ncfom = new Movie("New Country for Old Men"); //It's a sequel!
$ncfom-&gt;printMovieDetails();

// File IO
// File reading, easy method...
$contents = file_get_contents('Hello.php');
print "Hello has " . strlen($contents) . " chars\n";
// Writing to a file
$file_handle = f<span></span>open('/tmp/hello.txt', 'w');
fputs($file_handle, "Hello World");
fclose($file_handle);

// Command Executing
print `ls`; //Execute the command 'ls' and print its output
print "\n";

// Regular Expressions
$string = "Hello World";
if(preg_match('/^Hell/', $string)) print "Yup - its evil\n";
print preg_replace('/l([^l])/', "$1", $string); //Remove an 'l' from both words. Should print 'Helo Word'

/*
 * Specialized code
 */
// Database connectivity(native)
mysql_connect('localhost', 'root', '') or die("Cannot connect to the Database server");
mysql_select_db('Data') or die('Could not find a database called "Data"');

// Executing Query
$sql_handle = mysql_query('SELECT name,url,description FROM Comment LIMIT 1') or die('Query Error: ' . mysql_error());
while($row = mysql_fetch_assoc($sql_handle)) {
	print "Name	:	$row[name]\n";
	print "URL	:	$row[url]\n";
	print "Desc	:	$row[description]\n\n";
}
/* Just a note here - if you are going to use PHP with database in a production
 * system(and you will, trust me), use a Database abstraction layer rather than
 * the above mentioned native methods.
 */

print $_REQUEST['username']; // Method to get the value of the field 'username' after a form submit. Will not work at CLI execution
</code></pre>
<p>Save this to a file and keep it around for future reference &#8211; if you are just starting out with PHP</p>
<p>Coming up next &#8211; Python Hello Script.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/03/hello-script-for-php/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Learning a New Programming Language: The &#8216;Hello World&#8217; Method</title>
		<link>http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/</link>
		<comments>http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 17:15:39 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[world]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/</guid>
		<description><![CDATA[Learning a new programming language is fun &#8211; and essential if you want to stay competitive. I try to learn new languages all the time(my latest target is Haskell). As a result, I have a system to make learning new languages easier. This is for people who already know a programming language and want to [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro" align="right" src='http://www.bin-co.com/blog/wp-content/uploads/2008/03/hello.jpg' alt='Hello World Learning' /></p>
<p class="intro">Learning a new programming language is fun &#8211; and essential if you want to stay competitive. I try to learn new languages all the time(my latest target is Haskell). As a result, I have a system to make learning new languages easier. This is for people who already know a programming language and want to learn another one.</p>
<h2>Requirements</h2>
<h3>What you must have&#8230;</h3>
<dl>
<dt>The interpreter/compiler of the language you are learning</dt>
<dd>You must be able to run the program after writing it.</dd>
<dt>Language reference manual/documentation</dt>
<dd>Usually found at the site of the language. Put a shortcut to that on your desktop &#8211; because you will be using this all the time.</dd>
<dt>An easy to follow tutorial</dt>
<dd>Search for it in Google. If you find one and its hard to follow, ditch it and get another. You may not need this &#8211; as manual for most languages have a tutorial in them.</dd>
<dt>A &#8216;todo&#8217; project that you cannot live without</dt>
<dd>This is what forces you to learn the language &#8211; more on this later.</dd>
</dl>
<h3>What I would recommend you have&#8230;</h3>
<p>Having this will help you learn &#8211; but its not necessary.</p>
<dl>
<dt>A Net Connection</dt>
<dd>You may want to ask your doubt on the IRC channel. Or on a forum. Or to google the error message you got.</dd>
<dt>A Decent IDE</dt>
<dd>This may make your job easier &#8211; but if you have notepad, that&#8217;s enough.</dd>
</dl>
<h3>What you don&#8217;t need</h3>
<dl>
<dt>Books on the language</dt>
<dd>You may need a book to master the language &#8211; but you don&#8217;t need one to learn it.</dd>
<dt>A Teacher</dt>
<dd>Its helpful to have someone to clarify the doubts you may have &#8211; but <strong class="highlight">no one can teach you anything you cannot learn yourself</strong>.</dd>
</dl>
<h2>The Hello World Script</h2>
<p>First you have to create the &#8216;hello world&#8217; application. This is more than just &#8216;print &#8220;Hello World&#8221;&#8216; &#8211; it will act as a <strong class="highlight">cheatsheet for you until you familiarize yourself with the language</strong>. The point of this application is to use <strong class="highlight">all the most commonly used elements of a language and putting it in a single place</strong> so that you can refer to it later.</p>
<p>Your first job is to go to the tutorial, the manual and the internet until you create the Hello World application with the following stuff in it. I will provide an example &#8211; how the &#8216;hello world&#8217; application will look in PHP.</p>
<p>After each step run the application and make sure it works.</p>
<dl>
<dt>Print &#8220;Hello World\n&#8221;</dt>
<dd>
<p>Why do you think we call it a hello world application? Write the code to <strong class="highlight">print a string &#8216;hello world&#8217; and save it</strong> to a file. Now <strong class="highlight">run it using the interpreter</strong> &#8211; and make sure it works &#8211; see it in action.</p>
<pre><code class="php">
// Printing(IO)
print "Hello World!\n";
	</code></pre>
</dd>
<dt>Comments</dt>
<dd>
<p>Put a single line comment(like //) on top of the &#8220;print &#8216;hello world&#8217;&#8221; code and if your language supports it, a multiline comment(/* &#8211; */) as well. Run the script to make sure the comments work as advertised.</p>
<pre><code class="php">
// Single line comment.
/*
Mulitline comment.
*/
	</code></pre>
<p>I was just kidding about running the script to test the comments &#8211; you did&#8217;nt do it, did you?</p>
</dd>
<dt>Use a variable(a string and an integer) and a concatenation operator.</dt>
<dd>
<p>Create a variable called name(string) &#8211; and give it your name as the value. Create another integer variable and give it the current year. You don&#8217;t have to find it programatically &#8211; just put it as 2008 or something. Now you have to print out the a string &#8220;Hello, &lt;name&gt; &#8211; Welcome to year &lt;$year&gt;&#8221;. This string will let you concatenate two different type variable to a string &#8211; and it makes me feel like a time traveler <img src='http://www.bin-co.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p>Yeah &#8211; the value of variable name should appear at &lt;name&gt;. Use the concatenation operator if possible &#8211; in PHP, write</p>
<pre><code class="php">print "Hello, " . $name . " - welcome to year " . $year;</code></pre>
<p>instead of </p>
<pre><code class="php">print "Hello, $name - welcome to year $year";</code></pre>
<p>This is because different languages have different concatenation operators. The other stuff is the same almost universally. + refers to addition. &#8211; refers to subtraction. * is multiplication. My point is that <strong class="highlight">if you know the operators for one language, you know the operators for almost all languages</strong>. But the concatenation operator differs from language to language &#8211; its &#8216;+&#8217; in javascript, ruby. Its &#8216;.&#8217; in Perl, PHP, etc.</p>
<p>There are exceptions to this rule &#8211; &#8216;=&#8217; is the equality operator in SQL while it all other language its &#8216;==&#8217;. The assignment operator is &#8216;:=&#8217; in pascal &#8211; in all other it is &#8216;=&#8217;. If you notice any difference in any operator write some code using that operator in this section.</p>
</dd>
<dt>Use if/else if/else</dt>
<dd>
<p>Create something like this pseudo code&#8230;</p>
<pre><code class="pseudo">if (year &gt; 2008) {
	print "Welcome to the future - yes we have flying cars!"
}
else if(year &lt; 2008) {
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!"
}
else {
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo."
}</code></pre>
<p>In PHP, this section will look like this&#8230;</p>
<pre><code class="php">//If,else conditions
if ($year &gt; 2008) {
	print "Welcome to the future - yes, we have flying cars!";
}
else if($year &lt; 2008) {
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and decent, stay away from your parents!";
}
else {
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo.";
}
print "\n";
	</code></pre>
<p>If you use switch(and the new language supports switch), you can write an example of switch here. </p>
</dd>
<dt>Print &#8216;Hi there!&#8217; 3 times using a for loop</dt>
<dd>
<p>A PHP example of using for loop(my all time favorite loop)&#8230;</p>
<pre><code class="php">// For loop
for($i=0; $i&lt;3; $i++) {
	print "$i) Hi there!\n";
}
	</code></pre>
</dd>
<dt>Create a list(array) and iterate through it using while/for/foreach loop.</dt>
<dd>
<p>I am using a while loop here &#8211; to keep things different&#8230;</p>
<pre><code class="php">
//Numerical Array, While
$rules = array(
	'Do no harm',
	'Obey',
	'Continue Living'
);
$i = 0;
while($i&lt;count($rules)) {
	print "Rule " . ($i+1) . " : " . $rules[$i] . "\n";
	$i++;
}	</code></pre>
</dd>
<dt>Create a hash(associative array) and iterate through it.</dt>
<dd>
<p>If the language you are going to learn have &#8216;foreach&#8217;, this maybe the best time to use it&#8230;</p>
<pre><code class="php">// Associated array, foreach
$associated = array(
	'hello'	=>	'world',
	'foo'	=>	'bar',
	'lorem'	=>	'ipsum'
);
foreach($associated as $key => $value) {
	print "$key: $value\n";
}</code></pre>
</dd>
<dt>Create a function with an argument and a return.</dt>
<dd>
<p>If you need, you can create an example for call by reference, optional arguments, default argument value, variable argument count etc. as well &#8211; but they are not essential. Make sure you include the code to call a function as well.</p>
<pre><code class="php">// Function, argument, return, call
function hello($name) {
	return "Hello " . $name;
}
$hello_string = hello("Binny");</code></pre>
</dd>
</dl>
<h3>Optional Code</h3>
<p>I don&#8217;t usually included some of these in my &#8216;hello world&#8217; scripts &#8211; but they can be useful in some cases. Some may find them useful &#8211; so if you think you are going to use any of these, include it in your file.</p>
<dl>
<dt>Class, Objects, Member variables and functions</dt>
<dd>
<p>If you are a big fan of OOP, create the code for a class. Make sure it has all the following elements&#8230;</p>
<ul>
<li>At least one member variable</li>
<li>At least two member functions</li>
<li>Access the member variable and the other function from within a member function.</li>
<li>Create an object of this class</li>
<li>Call a member function using the object.</li>
</ul>
<pre><code class="php">// One for the OOP fanboys - Class, members, objects and stuff.
class Movie {
	public $name = '';
	public $rating = 0;

	function __construct($name) {
		$this-&gt;name = $name;
		$this-&gt;rateMovie();
	}
	function rateMovie() {
		$this-&gt;rating = (strlen($this-&gt;name) % 10) + 1; //IMDBs rating algorithm. True story!
	}

	function printMovieDetails() {
		print "Movie : {$this-&gt;name}\n";
		print "Rating : " . str_repeat('*', $this-&gt;rating) . "({$this-&gt;rating})\n\n";
	}
}
//Create the object
$ncfom = new Movie("New Country for Old Men"); //It's a sequel!
$ncfom-&gt;printMovieDetails();
</code></pre>
</dd>
<dt>File IO</dt>
<dd>
<p>Include this code &#8211; it is sure to come in useful someday. Unless you are learning JavaScript.</p>
<pre><code class="php">// File IO
// File reading, easy method...
$contents = file_get_contents('hello.php');
// Writing to a file
$file_handle = fop<span></span>en('/tmp/hello.txt', 'w');
fputs($file_handle, "Hello World");
fclose($file_handle);
	</code></pre>
</dd>
<dt>Command Execution</dt>
<dd>
<p>I tend to include this &#8211; but it may be unnecessary for you.</p>
<pre><code class="php">// Command Executing
print `ls`; //Execute the command 'ls' and print its output</code></pre>
</dd>
<dt>Regular Expressions</dt>
<dd>
<p>I always include them &#8211; I am a big fan of regular expressions. I have lost count of how many times <a href="http://xkcd.com/208/">they have saved the day</a>.</p>
<pre><code class="php">// Regular Expressions
$string = "Hello World";
if(preg_match('/^Hell/', $string)) print "Yup - its evil\n";
print preg_replace('/l([^l])/', "$1", $string); //Remove an 'l' from both words. Should print 'Helo Word'
	</code></pre>
</dd>
</dl>
<h3>Specialized Code</h3>
<p>The language you learn may have a specialized field which we may have not used yet. If so, put it down here.</p>
<p>If you are learning javascript, write some code to access DOM nodes here. If you are using PHP, database connectivity will go well here. If you are learning any web server side languages, write the code to fetch the POST/GET request values. For PHP, it may look something like this&#8230;</p>
<pre><code class="php">
// Database connectivity(native)
mysql_connect('localhost', 'root', '') or die("Cannot connect to the Database server");
mysql_select_db('Data') or die('Could not find a database called "Data"');

// Executing Query
$sql_handle = mysql_query('SELECT name,url,description FROM Comment LIMIT 1') or die('Query Error: ' . mysql_error());
while($row = mysql_fetch_assoc($sql_handle)) {
	print "Name	:	$row[name]\n";
	print "URL	:	$row[url]\n";
	print "Desc	:	$row[description]\n\n";
}
// Just a note here - if you are going to use PHP with database in a production system(and you will, trust me), use a Database abstraction layer rather than the above mentioned native methods.

print $_REQUEST['username']; // Method to get the value of the field 'username' after a form submit. Will not work at CLI execution
	</code></pre>
<h2>Project</h2>
<p>Next thing you need is <strong class="highlight">a project &#8211; which you are going to build using the new language</strong>. Some points that you have to look for when choosing the new project&#8230;</p>
<ol>
<li>It should not be a huge project.</li>
<li>At the same time, it should not be something trivial.</li>
<li>There must be something about the project which would force you to finish it.</li>
</ol>
<p>The third point needs a little explaining. You should not just pick any project that pops into your mind. It must be something that you need &#8211; something you could not live without. If it is important to you, you will have a <strong class="highlight">motivation to finish the project</strong>. Otherwise, you will drop the project at the first sign of trouble. But if its important to you, you will spend more time on it &#8211; you will look at documentation, post the problem in forums, ask others in IRC channels. And eventually, you will fix the problem. And you will finish the project.</p>
<p>While working on the project, keep the &#8216;hello world&#8217; open &#8211; you will find yourself referring to it often.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Article Templates &#8211; WordPress Plugin</title>
		<link>http://www.bin-co.com/blog/2007/10/article-templates-wordpress-plugin/</link>
		<comments>http://www.bin-co.com/blog/2007/10/article-templates-wordpress-plugin/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 17:30:12 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2007/10/article-templates-wordpress-plugin/</guid>
		<description><![CDATA[Article Templates wordpress plugin lets you create templates that can be used when writing a new post or page. This will be very useful if you are writing many post with the same structure. Download Article Templates 1.00.A Beta This is my first WordPress Plugin. It was easier to create than I expected. My plugin [...]]]></description>
			<content:encoded><![CDATA[<p class="intro"><a href="http://www.bin-co.com/tools/wordpress/plugins/article_templates/">Article Templates wordpress plugin</a> lets you create templates that can be used when writing a new post or page. This will be very useful if you are writing many post with the same structure.</p>
<p>Download <a href="http://www.bin-co.com/tools/wordpress/plugins/article_templates/article_templates.zip">Article Templates 1.00.A Beta</a></p>
<p><img src='http://www.bin-co.com/blog/wp-content/uploads/2007/10/template_dropdown.png' alt='Article Template Screenshot' /></p>
<p>This is my first WordPress Plugin. It was easier to create than I expected.</p>
<p>My plugin used the principles used in <a href="http://www.vincentprat.info/wordpress/2007/03/01/wordpress-plugin-post-templates/">Post Templates</a> plugin. It is another plugin to do the same thing &#8211; create templates for the post.</p>
<p>My plugin have a few advantages over the other plugin&#8230;</p>
<ul>
<li>Easier to use</li>
<li>The templates created by each user is accessable only to them</li>
</ul>
<p>There are a few disadvantages too&#8230;</p>
<ul>
<li>Javascript must be enabled for my plugin to work</li>
<li>Beta release &#8211; expect bugs</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2007/10/article-templates-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Nexty 2 will use PHP 5</title>
		<link>http://www.bin-co.com/blog/2007/08/nexty-2-will-use-php-5/</link>
		<comments>http://www.bin-co.com/blog/2007/08/nexty-2-will-use-php-5/#comments</comments>
		<pubDate>Sat, 04 Aug 2007 17:58:34 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[gophp5]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[nexty]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2007/08/nexty-2-will-use-php-5/</guid>
		<description><![CDATA[The next version of nexty is coming out very soon &#8211; and unlike the last version, Nexty 2 will require PHP 5. The main reason behind this change is GoPHP5. Go PHP 5 is a movement to promote the use of PHP5 in hosting servers and for projects. Another reason for this decision is that [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.bin-co.com/blog/wp-content/uploads/2007/08/gophp5_logo.png' alt='GoPHP5' align="right" class="intro" /></p>
<p class="intro">The next version of nexty is coming out very soon &#8211; and unlike the last version, Nexty 2 will require PHP 5.</p>
<p>The main reason behind this change is <a href="http://gophp5.org/">GoPHP5</a>. Go PHP 5 is a movement to promote the use of PHP5 in hosting servers and for projects.</p>
<p>Another reason for this decision is that <a href="http://www.bin-co.com/php/scripts/iframe/">iFrame</a>, the framework I used in Nexty, uses PHP 5.</p>
<p>If you are stuck with PHP 4, I cannot help it. You can still use the first version. But if you have a choice, <a href="http://www.php.net/index.php#2007-07-13-1">PHP 4 is dead</a> &#8211; move on.</p>
<h2>More on GoPHP5</h2>
<ul>
<li><a href="http://ifacethoughts.net/2007/07/18/the-php-rift/">The PHP Rift</a></li>
<li><a href="http://www.php-mag.net/magphpde/magphpde_news/psecom,id,27335,nodeid,5.html">Drupal Joins &#8216;Go PHP 5&#8242; Movement</a></li>
<li><a href="http://buzz.typo3.org/people/stucki/article/leaving-php4-behind/">Leaving PHP4 behind&#8230;</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2007/08/nexty-2-will-use-php-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Web Installer: The Code</title>
		<link>http://www.bin-co.com/blog/2007/07/web-installer-the-code/</link>
		<comments>http://www.bin-co.com/blog/2007/07/web-installer-the-code/#comments</comments>
		<pubDate>Tue, 10 Jul 2007 20:50:21 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[(X)HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[installer]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2007/07/web-installer-the-code/</guid>
		<description><![CDATA[The last two posts on web installer did not include any code. I wanted to dump all code into one post &#8211; this is it. Please note that this is what I did &#8211; you don&#8217;t have to copy my code as it is. Just look at the code and modify it according to your [...]]]></description>
			<content:encoded><![CDATA[<p class="intro">The <a href="http://www.bin-co.com/blog/2007/07/web-application-installer/">last two posts</a> on <a href="http://www.bin-co.com/blog/2007/07/3-simple-steps-to-create-a-web-installer/">web installer</a> did not include any code. I wanted to dump all code into one post &#8211; this is it. Please note that this is what I did &#8211; you don&#8217;t have to copy my code as it is. Just look at the code and modify it according to your needs.</p>
<h2>Getting Database Details</h2>
<h3>The Form/Frontend</h3>
<pre><code class="html">&lt;form action="" method="post"&gt;
&lt;h1&gt;Installation : Step 1&lt;/h1&gt;
Please provide the database connection details...
&lt;fieldset&gt;
&lt;legend&gt;Database Details&lt;/legend&gt;

&lt;label for='host'&gt;Database Host&lt;/label&gt;&lt;input type='text' name='host' value='localhost' /&gt;&lt;br /&gt;
&lt;label for='db_user'&gt;Database User&lt;/label&gt;&lt;input type='text' name='db_user' value='root' /&gt;&lt;br /&gt;
&lt;label for='password'&gt;Database Password&lt;/label&gt;&lt;input type='text' name='password' /&gt;&lt;br /&gt;
&lt;label for='database'&gt;Database&lt;/label&gt;&lt;input type='text' name='database' value='nexty' /&gt;&lt;br /&gt;
&lt;/fieldset&gt;

&lt;input type="hidden" name="step" value="2" /&gt;&lt;br /&gt;
&lt;input type="submit" name="action" value="Continue &gt;&gt;" /&gt;&lt;br /&gt;
&lt;/form&gt;</code></pre>
<h3>Backend</h3>
<p>Make sure that the given database details are correct.</p>
<pre><code class="php">// The First step is Setting up Database connection
//					   (the '2' is NOT a typo)
if($_REQUEST['step'] == 2) {
	//Save the data to the Session
	if(isset($_REQUEST['host'])) $_SESSION['host'] = $_REQUEST['host'];
	if(isset($_REQUEST['db_user'])) $_SESSION['db_user'] = $_REQUEST['db_user'];
	if(isset($_REQUEST['password'])) $_SESSION['password'] = $_REQUEST['password'];
	if(isset($_REQUEST['database'])) $_SESSION['database'] = $_REQUEST['database'];
	if(isset($_REQUEST['url'])) $_SESSION['url'] = $_REQUEST['url'];

	if(mysql_connect($_SESSION['host'],$_SESSION['db_user'],$_SESSION['password'])) { //Try to connect to the DB.
		$QUERY['success'][] = 'Connection to Database server successful';

		if(mysql_select_db($_SESSION['database'])) {//Select the provided database.
			$QUERY['success'][] = "Database '$_SESSION[database]' selected";

		} else {
			$QUERY['error'][] = 'The given database('.$_SESSION['database'].') does not exist. Please povide a valid database.';
			$_REQUEST['step'] = 1;
		}
	} else {
		$QUERY['error'][] = 'Unable to connect to the database. Make sure that the entered details are correct';
		$_REQUEST['step'] = 1;
	}
}</code></pre>
<p>Notice the over use of $_SESSION? That will come in use if I decide to add a Back button that enables the users to modify the data entered previously.</p>
<h2>Database Creation</h2>
<pre><code class="php">//Create the database only if it does not exist
//See if the database exists
$tables_sql = mysql_query("SHOW TABLES") or die(mysql_error());
$necessary_tables = array('Context','Project','Reminder','Setting','Task','TaskContext','User');
while($table = mysql_fetch_row($tables_sql)) {
	$necessary_tables = array_diff($necessary_tables,array($table[0])); //Remove the table from the array if it exists
}

//If there are no tables in the array that means that the all the necessary tables are present in the Database
//If some tables are missing, that means we have to create those tables...
if($necessary_tables) {
	$quries = &lt;&lt;&lt;END
-- Insert all the SQL to create the necessary tables here...
END;

	//Execute all the queries
	$all_quires = explode(";",$quries);
	$query_count = 0;
	foreach($all_quires as $query) {
		$query = trim($query);
		if($query) {
			@mysql_query($query);
			$query_count++;
		}
	}
	$QUERY['success'][] = "Database Populated.";
} else {
	$QUERY['error'][] = "Tables already in Database - I did not overwrite it. If you want to remove the old data, please delete the tables and run the installer script agian.";
}
</code></pre>
<h2>Saving the Database connection details</h2>
<pre><code class="php">
//I don't know how to escape the $ charector in heredocs - so I did this...
$config = '$config';//Heh, Heh <img src='http://www.bin-co.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />
$system_installed = '$system_installed';
$configuration = &lt;&lt;&lt;END
&lt;?php
//Configuration file for Nexty
$system_installed = true;
$config = array(
	'db_host'		=&gt;	'$_SESSION[host]',
	'db_user'		=&gt;	'$_SESSION[db_user]',
	'db_password'	=&gt;	'$_SESSION[password]',
	'db_database'	=&gt;	'$_SESSION[database]',
	'url'			=&gt;	'$_SESSION[url]',
	'absolute_path'	=&gt;	'$abs'
);

END;
if(is_writable('../configuration.php')) {
        // ...Write the $config text into the configuration.php file...

	$QUERY['success'][] = 'Saved the configuration file. &lt;a href="'.$_REQUEST['url'].'"&gt;Go to Nexty&lt;/a&gt;';
} else {
	$QUERY['error'][] = 'Configuration file (configuration.php) is not writable. Please copy the configuration code and enter it into the "configuration.php" file. Then press continue.';
}
</code></pre>
<p>See the <a href="https://nexty.svn.sourceforge.net/svnroot/nexty/install/">install folder for Nexty</a> in the Subversion server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2007/07/web-installer-the-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What I learned from Nexty</title>
		<link>http://www.bin-co.com/blog/2007/05/what-i-learned-from-nexty/</link>
		<comments>http://www.bin-co.com/blog/2007/05/what-i-learned-from-nexty/#comments</comments>
		<pubDate>Sat, 26 May 2007 19:36:29 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[nexty]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2007/05/what-i-learned-from-nexty/</guid>
		<description><![CDATA[Remember Nexty? Recently I was able to make the 1.0 version. Currently I am planning for the second version. But before starting on that I want to document the different things I learned when creating Nexty. These are a list of things you can expect on this series&#8230; Client Side CSS Icons Theming using CSS [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://nexty.sourceforge.net/' title='Nexty Logo'><img class="intro" align="right" src='http://www.bin-co.com/blog/wp-content/uploads/2007/04/nexty_logo.thumbnail.png' alt='Nexty Logo' /></a></p>
<p class="intro">Remember <a href="http://www.bin-co.com/blog/2007/04/nexty-10-released/">Nexty</a>? Recently I was able to make the 1.0 version. Currently I am planning for the second version. But before starting on that I want to document the different things I learned when creating Nexty. These are a list of things you can expect on this series&#8230;</p>
<h2>Client Side</h2>
<ul>
<li>CSS
<ul>
<li>Icons</li>
<li>Theming using CSS</li>
</ul>
</li>
<li>JavaScript
<ul>
<li>Ajax &#8211; Success/Failure Pattern</li>
</ul>
</li>
</ul>
<h2>Server Side</h2>
<ul>
<li>Installer</li>
<li>Framework</li>
<li>API</li>
<li>Distributed Apps</li>
</ul>
<p>Before starting, a small notice &#8211; I will include links to Nexty&#8217;s internal pages in this series. Most of these pages are behind a login. So I would advice that you get an <a href="http://www.bin-co.com/php/programs/apps/nexty/demo/users/register.php">account in Nexty</a> and <a href="http://www.bin-co.com/php/programs/apps/nexty/demo/users/login.php">login</a> into it using the &#8216;Remember Me&#8217; option enabled. This would make sure that you have the most seamless experience.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2007/05/what-i-learned-from-nexty/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

