<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Iyappan</title>
	<atom:link href="http://iyappan.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://iyappan.wordpress.com</link>
	<description></description>
	<lastBuildDate>Fri, 12 Nov 2010 08:52:18 +0000</lastBuildDate>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='iyappan.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Iyappan</title>
		<link>http://iyappan.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://iyappan.wordpress.com/osd.xml" title="Iyappan" />
	<atom:link rel='hub' href='http://iyappan.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Truth Behing LED TVs</title>
		<link>http://iyappan.wordpress.com/2010/11/12/truth-behing-led-tvs/</link>
		<comments>http://iyappan.wordpress.com/2010/11/12/truth-behing-led-tvs/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 08:52:18 +0000</pubDate>
		<dc:creator>iyappan</dc:creator>
				<category><![CDATA[Electronics]]></category>

		<guid isPermaLink="false">http://iyappan.wordpress.com/?p=125</guid>
		<description><![CDATA[LED backlighting in TVs has been a real boon for end users, while manufactures have been able to create stunningly slim televisions. It also keeps the environmentalists happy since there is no mercury used in LED backlit TVs there by giving you a greener product. We tested quite a few LED based LCD TVs in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=125&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>LED  backlighting in TVs has been a real boon for end users, while   manufactures have been able to create stunningly slim televisions. It   also keeps the environmentalists happy since there is no mercury used in   LED backlit TVs there by giving you a greener product. We tested quite  a  few LED based LCD TVs in the past and the difference in power   consumption is certainly visible while still maintaining a good   brightness level.</p>
<p>The problem with the term &#8220;LED backlit LCD&#8221; is  that it&#8217;s a bit too  long, which does not look good in advertisements  and posters.  Manufacturers have conveniently eliminated LCD and simply  highlight  &#8220;LED&#8221;, duping customers into thinking they are LED TVs, which  they  clearly aren&#8217;t. Today we&#8217;ll have a look at the different types of  LED  LCD TVs currently available that offer improved picture quality over   the other or even traditional LCD TVs.</p>
<p><strong>All LED Backlit TVs are not created equal</strong></p>
<p>The  first thing that you should know is that not all LED LCD TVs are   created equal. Just because the TV may have a sticker that says &#8220;LED&#8221; on   it does not mean you&#8217;ll get the same performance as the flagship  model.  Stop and think for a moment, if companies used the same  technologies in  their high-end and low-end products, no one would look  at the higher  end models, right?<br />
<img src="http://images.techtree.com/ttimages/story/113411_led_fullarray.jpg" alt="Posted Image" /><br />
There  are predominantly two types of LED backlighting technologies;  Edge-lit  LEDs and Full array LEDs. The first batch of LED TVs that came  out in  2009 were based on this technology and was first showcased by  Samsung.  Today you&#8217;ll find everyone using this technology in their  &#8220;cheaper&#8221; LED  LCD TVs. Edge-lit typically means the LEDs are placed  around the edge,  which allow companies to make slimmer TVs. There are  no major advantages  in this type of LED LCD over conventional LCDs when  it comes to picture  quality. In fact there are many uniformity issues  with edge-lit LEDs,  like certain areas of the TV tend to be brighter  than others, which we  noticed when we reviewed the <a title="External link" rel="nofollow external" href="http://www.techtree.com/India/Reviews/Sony_BRAVIA_40-inch_LED_TV_Go_Wireless/551-103246-898.html">Sony ZX1</a>. This is cheaper to produce than Full array LED LCDs, since they use a fewer number of LEDs.</p>
<p>The  other technology that can be found on most of high-end TVs of today  is  Full array LEDs. As the name suggests, there is a full array of  LEDs  (see pic) sitting behind the LCD panel. This obviously gives you a  more  even backlighting with little or no uniformity issues. Mid-range  to high  end models typically have this sort of backlighting, like the  Samsung  UNC6500 series. In terms of picture quality, there is no real   perceptible difference when compared to an LCD. The only advantage here   is lower power consumption and again a slimmer profile. The latest crop   of LED LCD TVs feature Local Dimming LED technology, which changes the   game altogether.</p>
<p><strong>What is Local Dimming LEDs?<br />
</strong><br />
LG  was the first to push out this technology in India and today almost  all  major brands have Local Dimming (LD) in their flagship models. LD  on  Full array LED TVs give you the better picture quality compared to  the  LD on Edge-lit TVs, which was introduced this year in the Samsung   UNC8000 series and LG LE5500 series. The LEDs used here are similar to   the Full array models except that the array is broken into different   zones and the LEDs in each zone can be dimmed or brightened depending on   the scene at hand.</p>
<p><img src="http://images.techtree.com/ttimages/story/113411_2.jpg" alt="Posted Image" /><br />
This  gives you very good black levels that rival plasmas, since the  LEDs in  the dark areas can be completely turned off. There is a little  catch  here though. The side effect of this is a slight blooming effect  noticed  up close when a brighter image appears suddenly over a dark  background.  This happens because when displaying a dark background, the  LEDs in  that area are mostly off and when a bright object suddenly  comes into  that area, the LED&#8217;s light up to full brightness and then  dim down to  the current selected picture mode. This happens very  quickly and isn&#8217;t  very noticeable when watching a movie, but if you  connect a PC to it  with a static background, it&#8217;s visible.<br />
Despite this, these TV&#8217;s are capable of delivering the best picture quality among LCD TVs.</p>
<p><strong>Commercial true LED TVs don&#8217;t exist yet<br />
</strong><br />
How  would one define a LED TV? It&#8217;s when a single LED is responsible  for  illuminating a single pixel on the screen, which is when you could  do  away with the LCD panel altogether. Today&#8217;s high-end LED LCD TVs  pack in  around 1500 LEDs and a typical full HD panel will have around 2  million  pixels. So in order for a TV to be classified as a true LED  TV, we  would have to have 2 million LEDs powering individual pixels,  which is  simply not possible today, and probably won&#8217;t be commercially  viable for  some time.</p>
<p>So you see, no matter how companies try to spin and  twist words and  create fancy slogans, if a TV uses an LCD panel, it&#8217;s  still an LCD TV  and not a LED TV. Sony and LG clearly mention this on  their site as LED  LCD TV, but Samsung seem to have conveniently dropped  the &#8220;LCD&#8221; from  all of their LED TVs, which would easily fool the  misinformed.</p>
<p><strong>Aren&#8217;t LED backlit TV&#8217;s supposed to be cheap?<br />
</strong><br />
Technically  LEDs should be cheaper to produce compared to CCFL based  LCDs, but our  guess is that manufacturers seem to be cashing in on the  hype and buzz  generated by none other than them. Everybody wants a  slimmer TV for  easier installation, more bragging rights, etc. and we  seemed to have  conditioned ourselves into thinking the extra price is  justified.</p>
<p>Another  reason for LED LCDs being expensive could very well be the   manufacturing process not being that mature as yet compared to LCDs.</p>
<p>It&#8217;s  probably cheaper to manufacture an LCD, since this technology has  been  around for a while now and manufacturing units are more wide  spread as  compared to LED LCDs, which just started hitting selves a  year back.</p>
<p><strong>What the Future holds<br />
</strong><br />
In  the next three to five years we should be able to see a considerable   drop in prices as we adopt newer technology for cheaper and better LED   LCD TVs. <a title="External link" rel="nofollow external" href="http://www.qdvision.com/">QD Vision</a> is a company that claims to have developed a breakthrough technology   called Quantum dots based on nano technology that is capable of   delivering up to 40% more power efficiency and a color gamut over 100%   of the NTSC spectrum. This is achievable due to the use of nano sized   semiconductor crystals capable of emitting pure red, green and blue   light.</p>
<p>You should see this technology hitting LED LCD models of  2011, which  isn&#8217;t far away. If you were on the fence on getting an LED  LCD TV then  we&#8217;d say get the one with Local Dimming LEDs if you can  afford it, or  else simply stick with a cheaper LCD TV, as the color  reproduction will  be better than the &#8220;cheaper&#8221; Edge-lit models. Better  still, if you  have a well functioning CRT at home, stick with that and  take the  plunge maybe next year when prices go down south.</p>
<p>SOURCE: Techtree</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iyappan.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iyappan.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iyappan.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iyappan.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iyappan.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iyappan.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iyappan.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iyappan.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iyappan.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iyappan.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iyappan.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iyappan.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iyappan.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iyappan.wordpress.com/125/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=125&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iyappan.wordpress.com/2010/11/12/truth-behing-led-tvs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/699ecf31da895465ad031bfcb8a44c5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iyappan</media:title>
		</media:content>

		<media:content url="http://images.techtree.com/ttimages/story/113411_led_fullarray.jpg" medium="image">
			<media:title type="html">Posted Image</media:title>
		</media:content>

		<media:content url="http://images.techtree.com/ttimages/story/113411_2.jpg" medium="image">
			<media:title type="html">Posted Image</media:title>
		</media:content>
	</item>
		<item>
		<title>How to install and configure Reliance Mobile broadband with Samsung Corby Speed SCH-F339 –  on Debian GNU/Linux (etch) or Ubuntu?</title>
		<link>http://iyappan.wordpress.com/2010/04/22/how-to-install-and-configure-reliance-mobile-broadband-with-samsung-corby-speed-sch-f339-%e2%80%93-on-debian-gnulinux-etch-or%c2%a0ubuntu/</link>
		<comments>http://iyappan.wordpress.com/2010/04/22/how-to-install-and-configure-reliance-mobile-broadband-with-samsung-corby-speed-sch-f339-%e2%80%93-on-debian-gnulinux-etch-or%c2%a0ubuntu/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 12:50:10 +0000</pubDate>
		<dc:creator>iyappan</dc:creator>
				<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://iyappan.wordpress.com/?p=119</guid>
		<description><![CDATA[Since I am using Mobile broadbrand with Reliance(Samsung Corby Speed) I was searching for drivers to install the modem in Linux machine. After a long search I tried for an hour and came up successfully installing the driver with Ubuntu(9.10). Follow the simple 7 steps to configure the USB EVDO modem to conneect in Ubuntu. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=119&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Since I am using Mobile broadbrand with Reliance(Samsung Corby Speed) I was searching for drivers to install the modem in Linux machine. After a long search I tried for an hour and came up successfully installing the driver with Ubuntu(9.10).</p>
<p><!-- 		@page { margin: 2cm } 		P { margin-bottom: 0.21cm } -->Follow the simple 7 steps to configure the USB EVDO modem to conneect in Ubuntu.</p>
<ol>
<li>Find The Modem, Vendor and ProdID</li>
<li>Detect the modem using modprobe</li>
<li>Plug in modem and see whether it 	has been found by using dmesg</li>
<li>Install dialer “wvdial” if it 	is not already installed</li>
<li>Configure /etc/wvdial.conf to put 	phone number, user name and password</li>
<li>Connect to Internet</li>
</ol>
<p>Before installing the modem login as root in Terminal (Sudo -i)</p>
<p><strong>STEP I Find The Modem, Vendor and ProdID</strong><br />
<code><span style="color:#3366ff;">cat /proc/bus/usb/devices</span></code><span style="color:#3366ff;"> </span><br />
S a m p l e<br />
<span style="color:#3366ff;"><span style="font-family:Tahoma;">cat /proc/bus/usb/devices </span></span><span style="font-family:Tahoma;"><br />
</span></p>
<p>Bus 006 Device 002: ID 04e8:6640 Samsung Electronics Co., Ltd Usb Modem Enumerator</p>
<p><span style="font-family:Tahoma;"><br />
</span>Note: the above command will give a list of devices connected.<br />
Please Find your device and its Vendor and ProdID</p>
<p>OR directly grep it<br />
<span style="color:#3366ff;">cat /proc/bus/usb/devices | grep Vendor</span></p>
<p>will give the Lines with word “Vendor” only<br />
These are the lines significant in my case</p>
<p><code><span style="color:#3366ff;">cat /proc/bus/usb/devices | grep Vendor</span></code><code><br />
</code><code><span style="color:#0000ff;"><br />
</span></code></p>
<p>OR use command</p>
<p><span style="color:#3366ff;">lsusb</span></p>
<p><span style="color:#3366ff;">lsusb</span></p>
<p>Using any of the above three you can find your EVDO modem – Vendor and ProdID</p>
<p>The vendor should be like</p>
<p>vendor=04e8</p>
<p>product=6640</p>
<p><strong>STEP II Detect the modem using modprobe<br />
</strong><br />
Now use modprob to detect the modem</p>
<p><span style="color:#3366ff;">modprobe usbserial vendor=0×04e8</span><span style="color:#3366ff;"> product=0×6640</span></p>
<p>Note : REMEMBER to add “0X” before your Vendor/ProdID<br />
if Vendor=04e8 on <span style="color:#3366ff;">modrpobe vendor=0×04e8</span><br />
if ProdID=6640 on <span style="color:#3366ff;">modrpobe product=0×6640</span></p>
<p>After Command ‘modprobe’ Plug the EVDO Modem to your USB port</p>
<p><strong>STEP III Plug in modem and see whether it has been found by using dmesg</strong></p>
<p>check the debug message using command ‘dmesg’</p>
<p><span style="color:#3366ff;">dmesg | tail</span></p>
<p>from the above dmesg command, you can find the modem device attached to which port.<br />
In my case it was <span style="color:#0000ff;">ttyACM0.</span></p>
<p><strong>STEP IV Install dialer “wvdial” if it is not already installed</strong><br />
use command “wvdial” for connecting to internet<br />
if ‘wvdial’ not install, install using command</p>
<p><span style="color:#3366ff;">apt-get install wvdial</span></p>
<p>(You can download wvdial from <span style="color:#339966;">http://open.nit.ca/download/wvdial-1.54.0.tar.gz</span></p>
<p>or <span style="color:#339966;">ftp://ftp.us.debian.org/debian/pool/main/w/wvdial/wvdial_1.54.0.orig.tar.gz</span>)(check for the latest version)<br />
<strong>STEP V Configure /etc/wvdial.conf to put phone number, user name and passowrd</strong><br />
then use command ‘wvdialconf’ for configuring wvdial</p>
<p>edit the file /etc/wvdial.conf to add phonenumber, username and passwd using command ‘gedit /etc/wvdial.conf’</p>
<p><span style="color:#3366ff;">gedit /etc/wvdial.conf</span></p>
<p>eg:<br />
<span style="color:#0000ff;">[Dialer Defaults]<br />
Stupid Mode = on<br />
Modem = /dev/</span><span style="color:#0000ff;">ttyACM0</span><br />
<span style="color:#0000ff;">Baud = 9216000<br />
Init = ATZ</span></p>
<p>Phone = #777<br />
Username =93xxxxxxxx<br />
Password = 93xxxxxxxx</p>
<p>New PPPD = yes</p>
<p><strong>STEP VI Connect to Internet</strong><br />
<span style="text-decoration:underline;">Connect to Internet</span></p>
<p>use command wvdial in the terminal</p>
<p><span style="color:#3366ff;">wvdial</span></p>
<p>now you are connected to internet  <img src="http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif" border="0" alt=":)" width="15" height="15" align="BOTTOM" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iyappan.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iyappan.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iyappan.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iyappan.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iyappan.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iyappan.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iyappan.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iyappan.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iyappan.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iyappan.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iyappan.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iyappan.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iyappan.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iyappan.wordpress.com/119/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=119&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iyappan.wordpress.com/2010/04/22/how-to-install-and-configure-reliance-mobile-broadband-with-samsung-corby-speed-sch-f339-%e2%80%93-on-debian-gnulinux-etch-or%c2%a0ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/699ecf31da895465ad031bfcb8a44c5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iyappan</media:title>
		</media:content>

		<media:content url="http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif" medium="image">
			<media:title type="html">:)</media:title>
		</media:content>
	</item>
		<item>
		<title>Display Images in Cake PHP</title>
		<link>http://iyappan.wordpress.com/2010/01/19/display-images-in-cake-php/</link>
		<comments>http://iyappan.wordpress.com/2010/01/19/display-images-in-cake-php/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 09:13:06 +0000</pubDate>
		<dc:creator>iyappan</dc:creator>
				<category><![CDATA[Cake PHP]]></category>

		<guid isPermaLink="false">http://iyappan.wordpress.com/?p=116</guid>
		<description><![CDATA[Today I face a problem as a beginner of CakePHP …How can I display image button with link in Cake. I wanted to use images as my buttons to edit and delete records and  navigate the admin pages. 1. Have to use HTML Helpers Image and Link, and we shall combine this 2. The CakePHP [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=116&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I face a problem as a beginner of CakePHP …How can I display image button with link in Cake. I wanted to use images as my buttons to edit and delete records and  navigate the admin pages.</p>
<p>1. Have to use HTML Helpers Image and Link, and we shall combine this 2. The CakePHP link helper is a handy tool to create links in your application. Here is the basic syntax:</p>
<p>&lt;?php echo $html-&gt;link(’help!’,’/help’); ?&gt;</p>
<p>And there’s a helper for creating images, too:</p>
<p>&lt;?php echo $html-&gt;image(’add.gif’); ?&gt;</p>
<p>Show  HTML code of the image as the link:</p>
<p>&lt;?php echo $html-&gt;link($html-&gt;image(’add.gif’),’/customers/add’)?&gt;</p>
<p>2. For Image,<br />
Syntax:</p>
<p>$html-&gt;image(string <em>$path</em>, array <em>$htmlAttributes</em>, boolean <em>$return = false);</em></p>
<p>Example:</p>
<p>$html-&gt;image(’/img/images/cancel.png’, array(’class’ =&gt; ’save_button’));<br />
3. For Link, the Syntax:</p>
<p>$html-&gt;link(string <em>$title, </em>string <em>$url, </em>array <em>$htmlAttributes, </em>string <em>$confirmMessage = false, </em>boolean <em>$escapeTitle = true, </em>boolean <em>$return = false</em>);</p>
<p>Example:</p>
<p>$html-&gt;link(’SAVE’, ‘/registers’, array(), false, false, false);</p>
<p>4. So to make an image clickable,</p>
<p>&lt;?php echo $html-&gt;link($html-&gt;image(’/img/images/cancel.png’,array(’class’ =&gt; ’save_button’)), ‘/registers’, array(), false, false, false); ?&gt;</p>
<p>And the best code is:<br />
&lt;?php echo $html-&gt;link($html-&gt;image(’add.gif’),’/customers/add’,array(’escape’=&gt;false))?&gt;</p>
<p>Hope it will help you to save time.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iyappan.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iyappan.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iyappan.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iyappan.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iyappan.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iyappan.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iyappan.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iyappan.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iyappan.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iyappan.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iyappan.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iyappan.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iyappan.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iyappan.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=116&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iyappan.wordpress.com/2010/01/19/display-images-in-cake-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/699ecf31da895465ad031bfcb8a44c5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iyappan</media:title>
		</media:content>
	</item>
		<item>
		<title>Real-World OOP With PHP and MySQL</title>
		<link>http://iyappan.wordpress.com/2009/11/03/real-world-oop-with-php-and-mysql/</link>
		<comments>http://iyappan.wordpress.com/2009/11/03/real-world-oop-with-php-and-mysql/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 10:12:07 +0000</pubDate>
		<dc:creator>iyappan</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://iyappan.wordpress.com/?p=112</guid>
		<description><![CDATA[Setting up the skeleton of our class is fairly simple once we figure out exactly what we need. First we need to make sure that we can do our basic MySQL functions. In order to do this, we need the following functions: Select Insert Delete Update Connect Disconnect Those seem pretty basic, but I’m sure [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=112&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Setting up the skeleton of our class is fairly simple once we figure out exactly what we need. First we need to make sure that we can do our basic MySQL functions. In order to do this, we need the following functions:</p>
<ul>
<li>Select</li>
<li>Insert</li>
<li>Delete</li>
<li>Update</li>
<li>Connect</li>
<li>Disconnect</li>
</ul>
<p>Those seem pretty basic, but I’m sure that as we go through, we’ll notice that a lot of them utilize some similar aspects, so we may have to create more classes. Here is what your class definition should look like. Notice that I made sure that the methods were created with the public keyword.</p>
<div>
<div>
<div><a href="http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/#"></a></div>
</div>
<ol>
<li>class Database</li>
<li>{</li>
<li> public function connect()   {   }</li>
<li> public function disconnect()    {   }</li>
<li> public function select()        {   }</li>
<li> public function insert()        {   }</li>
<li> public function delete()        {   }</li>
<li> public function update()    {   }</li>
<li>}</li>
</ol>
</div>
<pre>class Database
{
	public function connect()	{	}
	public function disconnect()	{	}
	public function select()		{	}
	public function insert()		{	}
	public function delete()		{	}
	public function update()	{	}
}</pre>
<h3>function connect()</h3>
<p>This function will be fairly basic, but creating it will require us to first create a few variables. Since we want to make sure that they can’t be accessed from outside our class, we will be setting them as private. These variables will be used to store the host, username, password and database for the connection. Since they will pretty much remain constant throughout, we don’t even need to create modifier or accessor methods for it. After that, we’d just need to create a simple mysql statement to connect to the database. Of course, since as programmers we always have to assume the user (even if it is us) will do something stupid, lets add an extra layer of precaution. We can check if the user has actually connected to the database first, and if they have, there really isn’t a need to re-connect. If they haven’t then we can use their credentials to connect.</p>
<div>
<ol>
<li>private db_host = ‘’;</li>
<li>private db_user = ‘’;</li>
<li>private db_pass = ‘’;</li>
<li>private db_name = ‘’;</li>
<li>public function connect()</li>
<li> {</li>
<li> if(!$this-&gt;con)</li>
<li> {</li>
<li> $myconn = @mysql_connect($this-&gt;db_host,$this-&gt;db_user,$this-&gt;db_pass);</li>
<li> if($myconn)</li>
<li> {</li>
<li> $seldb = @mysql_select_db($this-&gt;db_name,$myconn);</li>
<li> if($seldb)</li>
<li> {</li>
<li> $this-&gt;con = true;</li>
<li> return true;</li>
<li> } else</li>
<li> {</li>
<li> return false;</li>
<li> }</li>
<li> } else</li>
<li> {</li>
<li> return false;</li>
<li> }</li>
<li> } else</li>
<li> {</li>
<li> return true;</li>
<li> }</li>
<li> }</li>
</ol>
</div>
<pre>private db_host = ‘’;
private db_user = ‘’;
private db_pass = ‘’;
private db_name = ‘’; 

public function connect()
    {
        if(!$this-&gt;con)
        {
            $myconn = @mysql_connect($this-&gt;db_host,$this-&gt;db_user,$this-&gt;db_pass);
            if($myconn)
            {
                $seldb = @mysql_select_db($this-&gt;db_name,$myconn);
                if($seldb)
                {
                    $this-&gt;con = true;
                    return true;
                } else
                {
                    return false;
                }
            } else
            {
                return false;
            }
        } else
        {
            return true;
        }
    }</pre>
<p>As you can see, it makes use of some basic mysql functions and a bit of error checking to make sure that things are going according to plan. If it connects to the database successfully it will return true, and if not, it will return false. As an added bonus it will also set the connection variable to true if the connection was successfully complete.</p>
<h3>public function disconnect()</h3>
<p>This function will simply check our connection variable to see if it is set to true. If it is, that means that it is connected to the database, and our script will disconnect and return true. If not, then there really isn’t a need to do anything at all.</p>
<div>
<ol>
<li>public function disconnect()</li>
<li>{</li>
<li> if($this-&gt;con)</li>
<li> {</li>
<li> if(@mysql_close())</li>
<li> {</li>
<li> $this-&gt;con = false;</li>
<li> return true;</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> return false;</li>
<li> }</li>
<li> }</li>
<li>}</li>
</ol>
</div>
<pre>public function disconnect()
{
	if($this-&gt;con)
	{
		if(@mysql_close())
		{
                       $this-&gt;con = false;
			return true;
		}
		else
		{
			return false;
		}
	}
}</pre>
<h3>public function select()</h3>
<p>This is the first function where things begin to get a little complicated. Now we will be dealing with user arguments and returning the results properly. Since we don’t necessarily want to be able to use the results right away we’re also going to introduce a new variable called result, which will store the results properly. Apart from that we’re also going to create a new function that checks to see if a particular table exists in the database. Since all of our CRUD operations will require this, it makes more sense to create it separately rather than integrating it into the function. In this way, we’ll save space in our code and as such, we’ll be able to better optimize things later on. Before we go into the actual select statement, here is the tableExists function and the private results variable.</p>
<div>
<ol>
<li>private $result = array();</li>
<li>private function tableExists($table)</li>
<li> {</li>
<li> $tablesInDb = @mysql_query(&#8216;SHOW TABLES FROM &#8217;.$this-&gt;db_name.&#8217; LIKE &#8221;&#8216;.$table.&#8217;&#8221;&#8216;);</li>
<li> if($tablesInDb)</li>
<li> {</li>
<li> if(mysql_num_rows($tablesInDb)==1)</li>
<li> {</li>
<li> return true;</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> return false;</li>
<li> }</li>
<li> }</li>
<li> }</li>
</ol>
</div>
<pre>private $result = array(); 

private function tableExists($table)
    {
        $tablesInDb = @mysql_query('SHOW TABLES FROM '.$this-&gt;db_name.' LIKE "'.$table.'"');
        if($tablesInDb)
        {
            if(mysql_num_rows($tablesInDb)==1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }</pre>
<p>This function simply checks the database to see if the required table already exists. If it does it will return true and if not, it will return false.</p>
<div>
<div>
<div><a href="http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/#"></a><a href="http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/#"><br />
</a></div>
</div>
<ol>
<li>public function select($table, $rows = &#8217;*', $where = null, $order = null)</li>
<li> {</li>
<li> $q = &#8217;SELECT &#8217;.$rows.&#8217; FROM &#8217;.$table;</li>
<li> if($where != null)</li>
<li> $q .= &#8217; WHERE &#8217;.$where;</li>
<li> if($order != null)</li>
<li> $q .= &#8217; ORDER BY &#8217;.$order;</li>
<li> if($this-&gt;tableExists($table))</li>
<li> {</li>
<li> $query = @mysql_query($q);</li>
<li> if($query)</li>
<li> {</li>
<li> $this-&gt;numResults = mysql_num_rows($query);</li>
<li> for($i = 0; $i &lt; $this-&gt;numResults; $i++)</li>
<li> {</li>
<li> $r = mysql_fetch_array($query);</li>
<li> $key = array_keys($r);</li>
<li> for($x = 0; $x &lt; count($key); $x++)</li>
<li> {</li>
<li> // Sanitizes keys so only alphavalues are allowed</li>
<li> if(!is_int($key[$x]))</li>
<li> {</li>
<li> if(mysql_num_rows($query) &gt; 1)</li>
<li> $this-&gt;result[$i][$key[$x]] = $r[$key[$x]];</li>
<li> else if(mysql_num_rows($query) &lt; 1)</li>
<li> $this-&gt;result = null;</li>
<li> else</li>
<li> $this-&gt;result[$key[$x]] = $r[$key[$x]];</li>
<li> }</li>
<li> }</li>
<li> }</li>
<li> return true;</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> return false;</li>
<li> }</li>
<li> }</li>
<li>else</li>
<li> return false;</li>
<li> }</li>
</ol>
</div>
<pre>public function select($table, $rows = '*', $where = null, $order = null)
    {
        $q = 'SELECT '.$rows.' FROM '.$table;
        if($where != null)
            $q .= ' WHERE '.$where;
        if($order != null)
            $q .= ' ORDER BY '.$order;
        if($this-&gt;tableExists($table))
       {
        $query = @mysql_query($q);
        if($query)
        {
            $this-&gt;numResults = mysql_num_rows($query);
            for($i = 0; $i &lt; $this-&gt;numResults; $i++)
            {
                $r = mysql_fetch_array($query);
                $key = array_keys($r);
                for($x = 0; $x &lt; count($key); $x++)
                {
                    // Sanitizes keys so only alphavalues are allowed
                    if(!is_int($key[$x]))
                    {
                        if(mysql_num_rows($query) &gt; 1)
                            $this-&gt;result[$i][$key[$x]] = $r[$key[$x]];
                        else if(mysql_num_rows($query) &lt; 1)
                            $this-&gt;result = null;
                        else
                            $this-&gt;result[$key[$x]] = $r[$key[$x]];
                    }
                }
            }
            return true;
        }
        else
        {
            return false;
        }
        }
else
      return false;
    }</pre>
<p>While it does seem a little scary at first glance, this function really does a whole bunch of things. First off it accepts 4 arguments, 1 of which is required. The table name is the only thing that you need to pass to the function in order to get results back. However, if you want to customize it a bit more, you can do so by adding which rows will be pulled from the database, and you can even add a where and order clause. Of course, as long as you pass the first value, the result will default to their preset ones, so you don’t have to worry about setting all of them. The bit of code right after the arguments just serves to compile all our arguments into a select statement. Once that is done ,a check is done to see if the table exists, using our prior tableExists function. If it exists, then the function continues onwards and the query is performed. If not, it will fail.</p>
<p>The next section is the real magic of the code. What it does is gather the columns and data that was requested from the database. It then assigns it to our result variable. However, to make it easier for the end user, instead of auto-incrementing numeric keys, the names of the columns are used. In case you get more than one result each row that is returned is stored with a two dimensional array, with the first key being numerical and auto-incrementing, and the second key being the name of the column. If only one result is returned, then a one dimensional array is created with the keys being the columns. If no results are turned then the result variable is set to null. As I said earlier, it seems a bit confusing, but once you break things down into their individual sections, you can see that they are fairly simple and straightforward.</p>
<h3>public function insert()</h3>
<p>This function is a lot simpler than our prior one. It simply allows us to insert information into the database. As such we will require an additional argument to the name of the table. We will require a variable that corresponds to the values we wish to input. We can simply separate each value with a comma. Then, all we need to do is quickly check to see if our tableExists, and then build the insert statement by manipulating our arguments to form an insert statement. Then we just run our query.</p>
<div>
<ol>
<li>public function insert($table,$values,$rows = null)</li>
<li> {</li>
<li> if($this-&gt;tableExists($table))</li>
<li> {</li>
<li> $insert = &#8217;INSERT INTO &#8217;.$table;</li>
<li> if($rows != null)</li>
<li> {</li>
<li> $insert .= &#8217; (&#8216;.$rows.&#8217;)';</li>
<li> }</li>
<li> for($i = 0; $i &lt; count($values); $i++)</li>
<li> {</li>
<li> if(is_string($values[$i]))</li>
<li> $values[$i] = &#8217;&#8221;&#8216;.$values[$i].&#8217;&#8221;&#8216;;</li>
<li> }</li>
<li> $values = implode(&#8216;,&#8217;,$values);</li>
<li> $insert .= &#8217; VALUES (&#8216;.$values.&#8217;)';</li>
<li> $ins = @mysql_query($insert);</li>
<li> if($ins)</li>
<li> {</li>
<li> return true;</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> return false;</li>
<li> }</li>
<li> }</li>
<li> }</li>
</ol>
</div>
<pre>public function insert($table,$values,$rows = null)
    {
        if($this-&gt;tableExists($table))
        {
            $insert = 'INSERT INTO '.$table;
            if($rows != null)
            {
                $insert .= ' ('.$rows.')';
            }

            for($i = 0; $i &lt; count($values); $i++)
            {
                if(is_string($values[$i]))
                    $values[$i] = '"'.$values[$i].'"';
            }
            $values = implode(',',$values);
            $insert .= ' VALUES ('.$values.')';
            $ins = @mysql_query($insert);
            if($ins)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }</pre>
<p>As you can see, this function is a lot simpler than our rather complex select statement. Our delete function will actually be even simpler.</p>
<h3>public function delete()</h3>
<p>This function simply deletes either a table or a row from our database. As such we must pass the table name and an optional where clause. The where clause will let us know if we need to delete a row or the whole table. If the where clause is passed, that means that entries that match will need to be deleted. After we figure all that out, it’s just a matter of compiling our delete statement and running the query.</p>
<div>
<ol>
<li>public function delete($table,$where = null)</li>
<li> {</li>
<li> if($this-&gt;tableExists($table))</li>
<li> {</li>
<li> if($where == null)</li>
<li> {</li>
<li> $delete = &#8217;DELETE &#8217;.$table;</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> $delete = &#8217;DELETE FROM &#8217;.$table.&#8217; WHERE &#8217;.$where;</li>
<li> }</li>
<li> $del = @mysql_query($delete);</li>
<li> if($del)</li>
<li> {</li>
<li> return true;</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> return false;</li>
<li> }</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> return false;</li>
<li> }</li>
<li> }</li>
</ol>
</div>
<pre>public function delete($table,$where = null)
    {
        if($this-&gt;tableExists($table))
        {
            if($where == null)
            {
                $delete = 'DELETE '.$table;
            }
            else
            {
                $delete = 'DELETE FROM '.$table.' WHERE '.$where;
            }
            $del = @mysql_query($delete);

            if($del)
            {
                return true;
            }
            else
            {
               return false;
            }
        }
        else
        {
            return false;
        }
    }</pre>
<p>And finally we get to our last major function. This function simply serves to update a row in the database with some new information. However, because of the slightly more complex nature of it, it will come off as a bit larger and infinitely more confusing. Never fear, it follows much of the same pattern of our previous function. First it will use our arguments to create an update statement. It will then proceed to check the database to make sure that the tableExists. If it exists, it will simply update the appropriate row. The hard part, of course, comes when we try and create the update statement. Since the update statement has rules for multiple entry updating (IE – different columns in the same row via the cunning use of comma’s), we will need to take that into account and create a way to deal with it. I have opted to pass the where clause as a single array. The first element in the array will be the name of the column being updated, and the next will be the value of the column. In this way, every even number (including 0) will be the column name, and every odd number will be the new value. The code for performing this is very simple, and is presented below outside the function:</p>
<div>
<div>
<div><a href="http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/#"></a><a href="http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/#"><br />
</a></div>
</div>
<ol>
<li>for($i = 0; $i &lt; count($where); $i++)</li>
<li> {</li>
<li> if($i%2 != 0)</li>
<li> {</li>
<li> if(is_string($where[$i]))</li>
<li> {</li>
<li> if(($i+1) != null)</li>
<li> $where[$i] = &#8217;&#8221;&#8216;.$where[$i].&#8217;&#8221; AND &#8217;;</li>
<li> else</li>
<li> $where[$i] = &#8217;&#8221;&#8216;.$where[$i].&#8217;&#8221;&#8216;;</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> if(($i+1) != null)</li>
<li> $where[$i] = $where[$i]. &#8217; AND &#8217;;</li>
<li> else</li>
<li> $where[$i] = $where[$i];</li>
<li> }</li>
<li> }</li>
<li> }</li>
</ol>
</div>
<pre>for($i = 0; $i &lt; count($where); $i++)
            {
                if($i%2 != 0)
                {
                    if(is_string($where[$i]))
                    {
                        if(($i+1) != null)
                            $where[$i] = '"'.$where[$i].'" AND ';
                        else
                            $where[$i] = '"'.$where[$i].'"';
                    }
                   else
                   {
                        if(($i+1) != null)
                            $where[$i] = $where[$i]. ' AND ';
                        else
                            $where[$i] = $where[$i];
                  }
                }
            }</pre>
<p>The next section will create the part of the update statement that deals with actually setting the variables. Since you can change any number of values, I opted to go with an array where the key is the column and the value is the new value of the column. This way we can even do a check to see how many different values were passed to be updated and can add comma’s appropriately.</p>
<div>
<ol>
<li>$keys = array_keys($rows);</li>
<li> for($i = 0; $i &lt; count($rows); $i++)</li>
<li> {</li>
<li> if(is_string($rows[$keys[$i]]))</li>
<li> {</li>
<li> $update .= $keys[$i].&#8217;=&#8221;&#8216;.$rows[$keys[$i]].&#8217;&#8221;&#8216;;</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> $update .= $keys[$i].&#8217;=&#8217;.$rows[$keys[$i]];</li>
<li> }</li>
<li> // Parse to add commas</li>
<li> if($i != count($rows)-1)</li>
<li> {</li>
<li> $update .= &#8217;,';</li>
<li> }</li>
<li> }</li>
</ol>
</div>
<pre>$keys = array_keys($rows);
            for($i = 0; $i &lt; count($rows); $i++)
            {
                if(is_string($rows[$keys[$i]]))
                {
                    $update .= $keys[$i].'="'.$rows[$keys[$i]].'"';
                }
                else
                {
                    $update .= $keys[$i].'='.$rows[$keys[$i]];
                }
                // Parse to add commas
                if($i != count($rows)-1)
                {
                    $update .= ',';
                }
            }</pre>
<p>Now that we’ve got those two bits of logic out of the way, the rest of the update statement is easy. Here it is presented below:</p>
<div>
<ol>
<li>public function update($table,$rows,$where)</li>
<li> {</li>
<li> if($this-&gt;tableExists($table))</li>
<li> {</li>
<li> // Parse the where values</li>
<li> // even values (including 0) contain the where rows</li>
<li> // odd values contain the clauses for the row</li>
<li> for($i = 0; $i &lt; count($where); $i++)</li>
<li> {</li>
<li> if($i%2 != 0)</li>
<li> {</li>
<li> if(is_string($where[$i]))</li>
<li> {</li>
<li> if(($i+1) != null)</li>
<li> $where[$i] = &#8217;&#8221;&#8216;.$where[$i].&#8217;&#8221; AND &#8217;;</li>
<li> else</li>
<li> $where[$i] = &#8217;&#8221;&#8216;.$where[$i].&#8217;&#8221;&#8216;;</li>
<li> }</li>
<li> }</li>
<li> }</li>
<li> $where = implode(&#8216;=&#8217;,$where);</li>
<li> $update = &#8217;UPDATE &#8217;.$table.&#8217; SET &#8217;;</li>
<li> $keys = array_keys($rows);</li>
<li> for($i = 0; $i &lt; count($rows); $i++)</li>
<li> {</li>
<li> if(is_string($rows[$keys[$i]]))</li>
<li> {</li>
<li> $update .= $keys[$i].&#8217;=&#8221;&#8216;.$rows[$keys[$i]].&#8217;&#8221;&#8216;;</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> $update .= $keys[$i].&#8217;=&#8217;.$rows[$keys[$i]];</li>
<li> }</li>
<li> // Parse to add commas</li>
<li> if($i != count($rows)-1)</li>
<li> {</li>
<li> $update .= &#8217;,';</li>
<li> }</li>
<li> }</li>
<li> $update .= &#8217; WHERE &#8217;.$where;</li>
<li> $query = @mysql_query($update);</li>
<li> if($query)</li>
<li> {</li>
<li> return true;</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> return false;</li>
<li> }</li>
<li> }</li>
<li> else</li>
<li> {</li>
<li> return false;</li>
<li> }</li>
<li> }</li>
</ol>
</div>
<pre>public function update($table,$rows,$where)
    {
        if($this-&gt;tableExists($table))
        {
            // Parse the where values
            // even values (including 0) contain the where rows
            // odd values contain the clauses for the row
            for($i = 0; $i &lt; count($where); $i++)
            {
                if($i%2 != 0)
                {
                    if(is_string($where[$i]))
                    {
                        if(($i+1) != null)
                            $where[$i] = '"'.$where[$i].'" AND ';
                        else
                            $where[$i] = '"'.$where[$i].'"';
                    }
                }
            }
            $where = implode('=',$where);

            $update = 'UPDATE '.$table.' SET ';
            $keys = array_keys($rows);
            for($i = 0; $i &lt; count($rows); $i++)
           {
                if(is_string($rows[$keys[$i]]))
                {
                    $update .= $keys[$i].'="'.$rows[$keys[$i]].'"';
                }
                else
                {
                    $update .= $keys[$i].'='.$rows[$keys[$i]];
                }

                // Parse to add commas
                if($i != count($rows)-1)
                {
                    $update .= ',';
                }
            }
            $update .= ' WHERE '.$where;
            $query = @mysql_query($update);
            if($query)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return false;
        }
    }</pre>
<p>Now that we have that we’ve finished our last function, our simple CRUD interface for MySQL is complete. You can now create new entries, read specific entries from the database, update entries and delete things. Also, be creating and reusing this class you’ll find that you are saving yourself a lot of time and coding. Ah, the beauty of object oriented programming.</p>
<div><img src="http://nettuts.s3.amazonaws.com/135_crud/images/overview.png" border="0" alt="" /></div>
<h3>The Use</h3>
<p>So we&#8217;ve got our class all made, but how do we use it? This part is simple. Lets start by creating a very simple system database to use in our testing. I created a database called test, and then ran the MySQL statment. You can place it in any database that you like, just make sure that you change the connection variables at the top of the script to match:</p>
<div><img src="http://nettuts.s3.amazonaws.com/135_crud/images/mysqldb.png" border="0" alt="" /></div>
<p>The first line is commented out simply because not everyone will need it. If you need to run that more than once, you will need to uncomment it the second time to ensure that it creates the table.</p>
<p>Now that our table is created and populated, it&#8217;s time to run a few simple queries on it.</p>
<div>
<ol>
<li>&lt;?php;</li>
<li>include(&#8216;crud.php&#8217;);</li>
<li>$db = new Database();</li>
<li>$db-&gt;connect();</li>
<li>$db-&gt;select(&#8216;mysqlcrud&#8217;);</li>
<li>$res = $db-&gt;getResult();</li>
<li>print_r($res);</li>
<li>?&gt;</li>
</ol>
</div>
<pre>&lt;?php;
include('crud.php');
$db = new Database();
$db-&gt;connect();
$db-&gt;select('mysqlcrud');
$res = $db-&gt;getResult();
print_r($res);
?&gt;</pre>
<p>If done correctly, you should see the following:</p>
<div><img src="http://nettuts.s3.amazonaws.com/135_crud/images/select.png" border="0" alt="" /></div>
<p>Likewise we can go a step further and run an update query, and then output the results:</p>
<div>
<ol>
<li>&lt;?php;</li>
<li>$db-&gt;update(&#8216;mysqlcrud&#8217;,array(&#8216;name&#8217;=&gt;&#8217;Changed!&#8217;),array(&#8216;id&#8217;,1));</li>
<li>$db-&gt;update(&#8216;mysqlcrud&#8217;,array(&#8216;name&#8217;=&gt;&#8217;Changed2!&#8217;),array(&#8216;id&#8217;,2));</li>
<li>$res = $db-&gt;getResult();</li>
<li>print_r($res);</li>
<li>?&gt;</li>
</ol>
</div>
<pre>&lt;?php;
$db-&gt;update('mysqlcrud',array('name'=&gt;'Changed!'),array('id',1));
$db-&gt;update('mysqlcrud',array('name'=&gt;'Changed2!'),array('id',2));
$res = $db-&gt;getResult();
print_r($res);
?&gt;</pre>
<p>We should see this</p>
<div><img src="http://nettuts.s3.amazonaws.com/135_crud/images/update.png" border="0" alt="" /></div>
<p>Now for a simple insert statement:</p>
<div>
<div>
<div><a href="http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/#"></a></div>
</div>
<ol>
<li>;&lt;?php;</li>
<li>$db-&gt;insert(&#8216;mysqlcrud&#8217;,array(3,&#8221;Name 4&#8243;,&#8221;this@wasinsert.ed&#8221;));</li>
<li>$res = $db-&gt;getResult();</li>
<li>print_r($res);</li>
<li>?&gt;</li>
</ol>
</div>
<pre>;&lt;?php;
$db-&gt;insert('mysqlcrud',array(3,"Name 4","this@wasinsert.ed"));
$res = $db-&gt;getResult();
print_r($res);
?&gt;</pre>
<div><img src="http://nettuts.s3.amazonaws.com/135_crud/images/insert.png" border="0" alt="" /></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iyappan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iyappan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iyappan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iyappan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iyappan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iyappan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iyappan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iyappan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iyappan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iyappan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iyappan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iyappan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iyappan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iyappan.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=112&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iyappan.wordpress.com/2009/11/03/real-world-oop-with-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/699ecf31da895465ad031bfcb8a44c5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iyappan</media:title>
		</media:content>

		<media:content url="http://nettuts.s3.amazonaws.com/135_crud/images/overview.png" medium="image" />

		<media:content url="http://nettuts.s3.amazonaws.com/135_crud/images/mysqldb.png" medium="image" />

		<media:content url="http://nettuts.s3.amazonaws.com/135_crud/images/select.png" medium="image" />

		<media:content url="http://nettuts.s3.amazonaws.com/135_crud/images/update.png" medium="image" />

		<media:content url="http://nettuts.s3.amazonaws.com/135_crud/images/insert.png" medium="image" />
	</item>
		<item>
		<title>How to convert an array or object into a string in php</title>
		<link>http://iyappan.wordpress.com/2009/11/03/how-to-convert-an-array-or-object-into-a-string-in-php/</link>
		<comments>http://iyappan.wordpress.com/2009/11/03/how-to-convert-an-array-or-object-into-a-string-in-php/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 09:52:19 +0000</pubDate>
		<dc:creator>iyappan</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://iyappan.wordpress.com/?p=109</guid>
		<description><![CDATA[I am asked “How do I convert an array or object into a string” very frequently so I thought I would put a quick little tutorial together explaining the various different methods. Converting an array OR object into a string(BEST METHOD) We are going to use the functions serialize and unserialize. These functions are very [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=109&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am asked “How do I convert an array or object into a string” very frequently so I thought I would put a quick little tutorial together explaining the various different methods.</p>
<p><strong>Converting an array OR object into a string(BEST METHOD)</strong></p>
<p>We are going to use the functions serialize and unserialize.</p>
<p>These functions are very easy to use, for example converting an array or object you would do the following:</p>
<blockquote><p><code><br />
$string = serialize($objectorarray);<br />
</code></p></blockquote>
<p>Now to convert the string back into an object or array we would do:</p>
<blockquote><p><code><br />
$objectorarray = unserialize($string);<br />
</code></p></blockquote>
<p>It really is as simple as that, <strong>however sometimes the serialize function doesn’t do a good job at escaping characters so to get around this</strong> we do the following:</p>
<blockquote><p><code><br />
$string =base64_encode(serialize($objectorarray)); // This converts into a string</code></p>
<p>$objectorarray = unserialize( base64_decode($string)); // This converts a string into an array or object</p></blockquote>
<p><strong>Converting an array into a string (OLD FASHIONED METHOD).</strong></p>
<p><a href="http://www.colinjensen.co.uk/blog/web-related/php/www.php.net/implode"></a>Implode and Explode can be used to convert an array.</p>
<p>Look at my example below.</p>
<blockquote><p><code><br />
$myarray[] = 'Apple';</code></p>
<p>$myarray[] = &#8216;Orange&#8217;;</p>
<p>$string = implode(&#8216;|&#8217;,$myarray);</p>
<p>echo $string; // This would return Apple|Orange</p></blockquote>
<p>Using the example above, the implode function takes two parameters.  First our separator and second our array.</p>
<p>To now convert the string BACK into an array we use explode. See the example below.</p>
<blockquote><p><code><br />
$string = 'Apple|Orange';</code></p>
<p>$myarray = explode(&#8216;|&#8217;,$string);</p>
<p>print_r($myarray);</p></blockquote>
<p>The explode function takes pretty much the same parameters as implode except it looks for a string rather then an array.</p>
<p><strong>Why would you want to convert an array or object into a string?</strong></p>
<p>When saving vast amounts of data into a mysql table or even a text file, all you would need to do using the method above is save the string into the file or into a table row.  Very useful if you have plenty of dynamic data… No need to create lots of column names when you can save the object or array into a single row!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iyappan.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iyappan.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iyappan.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iyappan.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iyappan.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iyappan.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iyappan.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iyappan.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iyappan.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iyappan.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iyappan.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iyappan.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iyappan.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iyappan.wordpress.com/109/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=109&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iyappan.wordpress.com/2009/11/03/how-to-convert-an-array-or-object-into-a-string-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/699ecf31da895465ad031bfcb8a44c5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iyappan</media:title>
		</media:content>
	</item>
		<item>
		<title>Regular Expressions in PHP</title>
		<link>http://iyappan.wordpress.com/2009/11/03/regular-expressions-in-php/</link>
		<comments>http://iyappan.wordpress.com/2009/11/03/regular-expressions-in-php/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 09:48:41 +0000</pubDate>
		<dc:creator>iyappan</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://iyappan.wordpress.com/?p=105</guid>
		<description><![CDATA[Regular expressions are a language of their own. When you learn a new programming language, they&#8217;re this little sub-language that makes no sense at first glance. Many times you have to read another tutorial, article, or book just to understand the &#8220;simple&#8221; pattern described. Today, we&#8217;ll review eight regular expressions that you should know for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=105&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Regular expressions are a language of their own. When you learn a new programming language, they&#8217;re this little sub-language that makes no sense at first glance. Many times you have to read another tutorial, article, or book just to understand the &#8220;simple&#8221; pattern described. Today, we&#8217;ll review eight regular expressions that you should know for your next coding project.</p>
<p>This is what Wikipedia has to say about them:</p>
<blockquote><p>In computing, regular expressions provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters. Regular expressions (abbreviated as regex or regexp, with plural forms regexes, regexps, or regexen) are written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.</p></blockquote>
<p>Now, that doesn&#8217;t really tell me much about the actual patterns. The regexes I&#8217;ll be going over today contains characters such as \w, \s, \1, and many others that represent something totally different from what they look like.</p>
<p>If you&#8217;d like to learn a little about regular expressions before you continue reading this article, I&#8217;d suggest watching the <a href="http://www.multiurl.com/ga/regexdummies">Regular Expressions for Dummies</a> screencast series.</p>
<p>The eight regular expressions we&#8217;ll be going over today will allow you to match a(n): username, password, email, hex value (like #fff or #000), <a href="http://en.wikipedia.org/wiki/Slug_%28typesetting%29">slug</a>, URL, IP address, and an HTML tag. As the list goes down, the regular expressions get more and more confusing. The pictures for each regex in the beginning are easy to follow, but the last four are more easily understood by reading the explanation.</p>
<p>The key thing to remember about regular expressions is that they are almost read forwards and backwards at the same time. This sentence will make more sense when we talk about matching HTML tags.</p>
<p><em>Note:</em> The delimiters used in the regular expressions are forward slashes, &#8220;/&#8221;. Each pattern begins and ends with a delimiter. If a forward slash appears in a regex, we must escape it with a backslash: &#8220;\/&#8221;.</p>
<h2>Matching a Username</h2>
<div><img src="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/username.jpg" alt="Matching a username" /></div>
<h4>Pattern:</h4>
<div>
<ol>
<li>/^[a-z0-9_-]{3,16}$/</li>
</ol>
</div>
<pre>/^[a-z0-9_-]{3,16}$/</pre>
<h4>Description:</h4>
<p>We begin by telling the parser to find the beginning of the string (^), followed by any lowercase letter (a-z), number (0-9), an underscore, or a hyphen. Next, {3,16} makes sure that are at least 3 of those characters, but no more than 16. Finally, we want the end of the string ($).</p>
<h4>String that matches:</h4>
<p>my-us3r_n4m3</p>
<h4>String that doesn&#8217;t match:</h4>
<p>th1s1s-wayt00_l0ngt0beausername (too long)</p>
<h2>Matching a Password</h2>
<div><img src="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/password.jpg" alt="Matching a password" /></div>
<h4>Pattern:</h4>
<div>
<ol>
<li>/^[a-z0-9_-]{6,18}$/</li>
</ol>
</div>
<pre>/^[a-z0-9_-]{6,18}$/</pre>
<h4>Description:</h4>
<p>Matching a password is very similar to matching a username. The only difference is that instead of 3 to 16 letters, numbers, underscores, or hyphens, we want 6 to 18 of them ({6,18}).</p>
<h4>String that matches:</h4>
<p>myp4ssw0rd</p>
<h4>String that doesn&#8217;t match:</h4>
<p>mypa$$w0rd (contains a dollar sign)</p>
<h2>Matching a Hex Value</h2>
<div><img src="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/hex-copy.jpg" alt="Matching a hex valud" /></div>
<h4>Pattern:</h4>
<div>
<ol>
<li>/^#?([a-f0-9]{6}|[a-f0-9]{3})$/</li>
</ol>
</div>
<pre>/^#?([a-f0-9]{6}|[a-f0-9]{3})$/</pre>
<h4>Description:</h4>
<p>We begin by telling the parser to find the beginning of the string (^). Next, a number sign is optional because it is followed a question mark. The question mark tells the parser that the preceding character — in this case a number sign — is optional, but to be &#8220;greedy&#8221; and capture it if it&#8217;s there. Next, inside the first group (first group of parentheses), we can have two different situations. The first is any lowercase letter between a and f or a number six times. The vertical bar tells us that we can also have three lowercase letters between a and f or numbers instead. Finally, we want the end of the string ($).</p>
<p>The reason that I put the six character before is that parser will capture a hex value like #ffffff. If I had reversed it so that the three characters came first, the parser would only pick up #fff and not the other three f&#8217;s.</p>
<h4>String that matches:</h4>
<p>#a3c113</p>
<h4>String that doesn&#8217;t match:</h4>
<p>#4d82h4 (contains the letter h)</p>
<h2>Matching a Slug</h2>
<div><img src="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/slug.jpg" alt="Matching a slug" /></div>
<h4>Pattern:</h4>
<div>
<ol>
<li>/^[a-z0-9-]+$/</li>
</ol>
</div>
<pre>/^[a-z0-9-]+$/</pre>
<h4>Description:</h4>
<p>You will be using this regex if you ever have to work with mod_rewrite and pretty URL&#8217;s. We begin by telling the parser to find the beginning of the string (^), followed by one or more (the plus sign) letters, numbers, or hyphens. Finally, we want the end of the string ($).</p>
<h4>String that matches:</h4>
<p>my-title-here</p>
<h4>String that doesn&#8217;t match:</h4>
<p>my_title_here (contains underscores)</p>
<h2>Matching an Email</h2>
<div><img src="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/email.jpg" alt="Matching an email" /></div>
<h4>Pattern:</h4>
<div>
<ol>
<li>/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/</li>
</ol>
</div>
<pre>/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/</pre>
<h4>Description:</h4>
<p>We begin by telling the parser to find the beginning of the string (^). Inside the first group, we match one or more lowercase letters, numbers, underscores, dots, or hyphens. I have escaped the dot because a non-escaped dot means any character. Directly after that, there must be an at sign. Next is the domain name which must be: one or more lowercase letters, numbers, underscores, dots, or hyphens. Then another (escaped) dot, with the extension being two to six letters or dots. I have 2 to 6 because of the country specific TLD&#8217;s (.ny.us or .co.uk). Finally, we want the end of the string ($).</p>
<h4>String that matches:</h4>
<p>john@doe.com</p>
<h4>String that doesn&#8217;t match:</h4>
<p>john@doe.something (TLD is too long)</p>
<h2>Matching a URL</h2>
<div><img src="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/url.jpg" alt="Matching a url" /></div>
<h4>Pattern:</h4>
<div>
<ol>
<li>/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/</li>
</ol>
</div>
<pre>/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/</pre>
<h4>Description:</h4>
<p>This regex is almost like taking the ending part of the above regex, slapping it between &#8220;http://&#8221; and some file structure at the end. It sounds a lot simpler than it really is. To start off, we search for the beginning of the line with the caret.</p>
<p>The first capturing group is all option. It allows the URL to begin with &#8220;http://&#8221;, &#8220;https://&#8221;, or neither of them. I have a question mark after the s to allow URL&#8217;s that have http or https. In order to make this entire group optional, I just added a question mark to the end of it.</p>
<p>Next is the domain name: one or more numbers, letters, dots, or hypens followed by another dot then two to six letters or dots. The following section is the optional files and directories. Inside the group, we want to match any number of forward slashes, letters, numbers, underscores, spaces, dots, or hyphens. Then we say that this group can be matched as many times as we want. Pretty much this allows multiple directories to be matched along with a file at the end. I have used the star instead of the question mark because the star says zero <strong>or more</strong>, not zero <strong>or one</strong>. If a question mark was to be used there, only one file/directory would be able to be matched.</p>
<p>Then a trailing slash is matched, but it can be optional. Finally we end with the end of the line.</p>
<h4>String that matches:</h4>
<p>http://net.tutsplus.com/about</p>
<h4>String that doesn&#8217;t match:</h4>
<p>http://google.com/some/file!.html (contains an exclamation point)</p>
<h2>Matching an IP Address</h2>
<div><img src="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/ip.jpg" alt="Matching an IP address" /></div>
<h4>Pattern:</h4>
<div>
<ol>
<li>/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/</li>
</ol>
</div>
<pre>/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/</pre>
<h4>Description:</h4>
<p>Now, I&#8217;m not going to lie, I didn&#8217;t write this regex; I got it from <a href="http://www.regular-expressions.info/regexbuddy/ipaccurate.html">here</a>. Now, that doesn&#8217;t mean that I can&#8217;t rip it apart character for character.</p>
<p>The first capture group really isn&#8217;t a captured group because</p>
<div>
<ol>
<li>?:</li>
</ol>
</div>
<pre>?:</pre>
<p>was placed inside which tells the parser to not capture this group (more on this in the last regex). We also want this non-captured group to be repeated three times — the {3} at the end of the group. This group contains another group, a subgroup, and a literal dot. The parser looks for a match in the subgroup then a dot to move on.</p>
<p>The subgroup is also another non-capture group. It&#8217;s just a bunch of character sets (things inside brackets): the string &#8220;25&#8243; followed by a number between 0 and 5; or the string &#8220;2&#8243; and a number between 0 and 4 and any number; or an optional zero or one followed by two numbers, with the second being optional.</p>
<p>After we match three of those, it&#8217;s onto the next non-capturing group. This one wants: the string &#8220;25&#8243; followed by a number between 0 and 5; or the string &#8220;2&#8243; with a number between 0 and 4 and another number at the end; or an optional zero or one followed by two numbers, with the second being optional.</p>
<p>We end this confusing regex with the end of the string.</p>
<h4>String that matches:</h4>
<p>73.60.124.136 (no, that is not my IP address <img src='http://s1.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> )</p>
<h4>String that doesn&#8217;t match:</h4>
<p>256.60.124.136 (the first group must be &#8220;25&#8243; and a number between zero and <strong>five</strong>)</p>
<h2>Matching an HTML Tag</h2>
<div><img src="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/htmltag.jpg" alt="Matching an HTML tag" /></div>
<h4>Pattern:</h4>
<div>
<div>
<div><a href="http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/#">view plain</a><a href="http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/#">copy to clipboard</a><a href="http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/#">print</a><a href="http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/#">?</a></div>
</div>
<ol>
<li>/^&lt;([a-z]+)([^&lt;]+)*(?:&gt;(.*)&lt;\/\1&gt;|\s+\/&gt;)$/</li>
</ol>
</div>
<pre>/^&lt;([a-z]+)([^&lt;]+)*(?:&gt;(.*)&lt;\/\1&gt;|\s+\/&gt;)$/</pre>
<h4>Description:</h4>
<p>One of the more useful regexes on the list. It matches any HTML tag with the content inside. As usually, we begin with the start of the line.</p>
<p>First comes the tag&#8217;s name. It must be one or more letters long. This is the first capture group, it comes in handy when we have to grab the closing tag. The next thing are the tag&#8217;s attributes. This is any character but a greater than sign (&gt;). Since this is optional, but I want to match more than one character, the star is used. The plus sign makes up the attribute and value, and the star says as many attributes as you want.</p>
<p>Next comes the third non-capture group. Inside, it will contain either a greater than sign, some content, and a closing tag; or some spaces, a forward slash, and a greater than sign. The first option looks for a greater than sign followed by any number of characters, and the closing tag. \1 is used which represents the content that was captured in the first capturing group. In this case it was the tag&#8217;s name. Now, if that couldn&#8217;t be matched we want to look for a self closing tag (like an img, br, or hr tag). This needs to have one or more spaces followed by &#8220;/&gt;&#8221;.</p>
<p>The regex is ended with the end of the line.</p>
<h4>String that matches:</h4>
<p>&lt;a href=&#8221;http://net.tutsplus.com/&#8221;&gt;Nettuts+&lt;/a&gt;</p>
<h4>String that doesn&#8217;t match:</h4>
<p>&lt;img src=&#8221;img.jpg&#8221; alt=&#8221;My image&gt;&#8221; /&gt; (attributes can&#8217;t contain greater than signs)</p>
<h2>Conclusion</h2>
<p>I hope that you have grasped the ideas behind regular expressions a little bit better. Hopefully you&#8217;ll be using these regexes in future projects! Many times you won&#8217;t need to decipher a regex character by character, but sometimes if you do this it helps you learn. Just remember, don&#8217;t be afraid of regular expressions, they might not seem it, but they make your life a lot easier. Just try and pull out a tag&#8217;s name from a string without regular expressions! <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iyappan.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iyappan.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iyappan.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iyappan.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iyappan.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iyappan.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iyappan.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iyappan.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iyappan.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iyappan.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iyappan.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iyappan.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iyappan.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iyappan.wordpress.com/105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=105&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iyappan.wordpress.com/2009/11/03/regular-expressions-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/699ecf31da895465ad031bfcb8a44c5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iyappan</media:title>
		</media:content>

		<media:content url="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/username.jpg" medium="image">
			<media:title type="html">Matching a username</media:title>
		</media:content>

		<media:content url="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/password.jpg" medium="image">
			<media:title type="html">Matching a password</media:title>
		</media:content>

		<media:content url="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/hex-copy.jpg" medium="image">
			<media:title type="html">Matching a hex valud</media:title>
		</media:content>

		<media:content url="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/slug.jpg" medium="image">
			<media:title type="html">Matching a slug</media:title>
		</media:content>

		<media:content url="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/email.jpg" medium="image">
			<media:title type="html">Matching an email</media:title>
		</media:content>

		<media:content url="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/url.jpg" medium="image">
			<media:title type="html">Matching a url</media:title>
		</media:content>

		<media:content url="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/ip.jpg" medium="image">
			<media:title type="html">Matching an IP address</media:title>
		</media:content>

		<media:content url="http://nettuts.s3.amazonaws.com/404_regularExpressions/images/htmltag.jpg" medium="image">
			<media:title type="html">Matching an HTML tag</media:title>
		</media:content>
	</item>
		<item>
		<title>OOPS in PHP</title>
		<link>http://iyappan.wordpress.com/2009/11/03/oops-in-php/</link>
		<comments>http://iyappan.wordpress.com/2009/11/03/oops-in-php/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 09:44:21 +0000</pubDate>
		<dc:creator>iyappan</dc:creator>
				<category><![CDATA[OOPS in PHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://iyappan.wordpress.com/?p=103</guid>
		<description><![CDATA[Object Oriented Programming in PHP This article introduces Object Oriented Programming (OOP) in PHP. Luis shows you how to code less and better by using some OOP concepts and PHP tricks.Object Oriented Programming in any language is the use of objects to represent functional parts of an application and real life entities. For example you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=103&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Object Oriented Programming in PHP</p>
<p>This article introduces Object Oriented Programming (OOP) in PHP. Luis shows you how to code less and better by using some OOP concepts and PHP tricks.Object Oriented Programming in any language is the use of objects to represent functional parts of an application and real life entities. For example you may have a Person object to hold the data related to a person and even provide some functionality that this person may be capable of.</p>
<p>&nbsp;</p>
<p>Object Oriented Programming has long been used in games to represent the objects such as a User or an Enemy, or even a Weapon. This amazing way of programming has proven just as useful in software and web development.</p>
<p>&nbsp;</p>
<p>In my opinion any OOP language should have:</p>
<p>Abstract data types and information hiding</p>
<p>Inheritance</p>
<p>Polymorphism</p>
<p>This can all be done using PHP classes:</p>
<p>&nbsp;</p>
<p>&lt;?php</p>
<p>class Something {</p>
<p>// In OOP classes are usually named starting with a cap letter.</p>
<p>var $x;</p>
<p>function setX($v) {</p>
<p>// Methods start in lowercase then use lowercase to separate</p>
<p>// words in the method name example getValueOfArea()</p>
<p>$this-&gt;x=$v;</p>
<p>}</p>
<p>function getX() {</p>
<p>return $this-&gt;x;</p>
<p>}</p>
<p>}</p>
<p>?&gt;</p>
<p>&nbsp;</p>
<p>Of course you can use your own nomenclature but having a standardized one is useful.</p>
<p>&nbsp;</p>
<p>Object Oriented Programming in PHP – Data Members and Functions</p>
<p>&nbsp;</p>
<p>Data members are defined in PHP using a “var” declaration inside the class and they have no type until they are assigned a value. A data member might be an integer, an array, an associative array or even an object.</p>
<p>&nbsp;</p>
<p>Methods are defined as functions inside the class, to access data members inside the methods you have to use $this-&gt;name, otherwise the variable is local to the method.</p>
<p>&nbsp;</p>
<p>You create an object using the new operator:</p>
<p>&nbsp;</p>
<p>$obj=new Something;</p>
<p>Then you can use member functions like:</p>
<p>$obj-&gt;setX(5);</p>
<p>$see=$obj-&gt;getX();</p>
<p>The setX member function assigns 5 to the x data member in the object obj (not in the class), then getX returns its value; 5 in this case.</p>
<p>&nbsp;</p>
<p>You can access the data members from the object reference using for example: $obj-&gt;x=6. However, this is not a very good OOP practice.</p>
<p>&nbsp;</p>
<p>I encourage you to set data members by defining methods to set them and access the data members by using retrieving methods.</p>
<p>&nbsp;</p>
<p>You’ll be a good OOP programmer if you consider data members inaccessible and only use methods from the object handler. Unfortunately PHP doesn’t have a way to declare a data member private so bad code is allowed.</p>
<p>&nbsp;</p>
<p>Inheritance</p>
<p>&nbsp;</p>
<p>Inheritance is easy in PHP using the extends keyword:</p>
<p>&nbsp;</p>
<p>&lt;?php</p>
<p>class Another extends Something {</p>
<p>var $y;</p>
<p>function setY($v) {</p>
<p>// Methods start in lowercase then use uppercase initials to</p>
<p>// separate words in the method name example getValueOfArea()</p>
<p>this-&gt;y=$v;</p>
<p>}</p>
<p>function getY() {</p>
<p>return $this-&gt;y;</p>
<p>}</p>
<p>}</p>
<p>?&gt;</p>
<p>&nbsp;</p>
<p>Objects of the class “Another” now have all the data members and methods of the parent class (Something) plus its own data members and methods.</p>
<p>You can use:</p>
<p>$obj2=new Something;</p>
<p>$obj2-&gt;setX(6);</p>
<p>$obj2-&gt;setY(7);</p>
<p>&nbsp;</p>
<p>Multiple-inheritance is not supported so you can’t make a class extend two or more different classes.</p>
<p>&nbsp;</p>
<p>You can override a method in the derived class by redefining it. If we redefine getX in “Another” we can no longer access method getX in “Something”.</p>
<p>&nbsp;</p>
<p>If you declare a data member in a derived class with the same name as a data member in a Base class the derived data member “hides” the base class data member when you access it.</p>
<p>&nbsp;</p>
<p>Object Oriented Programming in PHP – Constructors</p>
<p>&nbsp;</p>
<p>You might define constructors in your classes; constructors are methods with the same name as the class and are called when you create an object of the class, for example:</p>
<p>&nbsp;</p>
<p>&lt;?php</p>
<p>class Something {</p>
<p>var $x;</p>
<p>function Something($y) {</p>
<p>$this-&gt;x=$y;</p>
<p>}</p>
<p>function setX($v) {</p>
<p>$this-&gt;x=$v;</p>
<p>}</p>
<p>function getX() {</p>
<p>return $this-&gt;x;</p>
<p>}</p>
<p>}</p>
<p>?&gt;</p>
<p>&nbsp;</p>
<p>So you can create an object using:</p>
<p>$obj=new Something(6);</p>
<p>&nbsp;</p>
<p>…and the constructor automatically assigns 6 to the data member x.</p>
<p>&nbsp;</p>
<p>Constructors and methods are normal PHP functions so you can use default arguments.</p>
<p>&nbsp;</p>
<p>function Something($x=”3″,$y=”5″);</p>
<p>Then:</p>
<p>&nbsp;</p>
<p>$obj=new Something(); // x=3 and y=5</p>
<p>$obj=new Something(8); // x=8 and y=5</p>
<p>$obj=new Something(8,9); // x=8 and y=9</p>
<p>&nbsp;</p>
<p>Default arguments are used in the C++ way so you can’t pass a value to Y and let X take the default value. Arguments are assigned from left to right and when no more arguments are found if the function expected more they take the default values.</p>
<p>&nbsp;</p>
<p>When an object of a derived class is created only its constructor is called the constructor of the Parent class is not called.</p>
<p>&nbsp;</p>
<p>This is a gotcha of PHP because constructor chaining is a classic feature of OOP, if you want to call the base class constructor you have to do it explicitly from the derived class constructor.</p>
<p>&nbsp;</p>
<p>It works because all methods of the parent class are available at the derived class due to inheritance.</p>
<p>&nbsp;</p>
<p>&lt;?php</p>
<p>function Another() {</p>
<p>$this-&gt;y=5;</p>
<p>$this-&gt;Something(); //explicit call to base class constructor.</p>
<p>}</p>
<p>?&gt;</p>
<p>&nbsp;</p>
<p>Abstract Classes</p>
<p>&nbsp;</p>
<p>A nice mechanism in OOP is the use of Abstract Classes; abstract classes are classes that cannot be instantiated and the only purpose is to define an interface for its derived classes.</p>
<p>&nbsp;</p>
<p>Designers often use Abstract classes to force programmers to derive classes from certain base classes, so they can be certain that the new classes have some desired functionality.</p>
<p>&nbsp;</p>
<p>There’s no standard way to do that in PHP but, if you do need this feature, just define the base class and put a “die” call in its constructor so you can be sure that the base class is never instantiated.</p>
<p>&nbsp;</p>
<p>Now define the methods (interface) putting “die” statements in each one so if in a derived class a programmer doesn’t override the method then an error is raised.</p>
<p>&nbsp;</p>
<p>Furthermore you might need to be sure, since PHP has no types, that some object is from a class derived from your base class, then add a method in the base class to identify the class (return “some id”) and verify this when you receive an object as an argument.</p>
<p>&nbsp;</p>
<p>Of course this doesn’t work if the evil programmer overrides the method in the derived class but generally the problem is dealing with lazy programmers not evil ones! Of course it’s better to keep the base class unreachable from the programmers, just print the interface and make them work!</p>
<p>&nbsp;</p>
<p>There’re no destructors in PHP.</p>
<p>&nbsp;</p>
<p>Object Oriented Programming in PHP – Overloading</p>
<p>&nbsp;</p>
<p>Overloading (which is different from overriding) is not supported in PHP. In OOP you “overload” a method when you define two/more methods with the same name but different number or type of parameters (depending upon the language).</p>
<p>&nbsp;</p>
<p>PHP is a loosely typed language so overloading by types won’t work, however overloading by number of parameters doesn’t work either.</p>
<p>&nbsp;</p>
<p>It’s very nice sometimes in OOP to overload constructors so you can build the object in different ways (passing different number of arguments). A trick to do something like that in PHP is:</p>
<p>&nbsp;</p>
<p>&lt;?php</p>
<p>class Myclass {</p>
<p>function Myclass() {</p>
<p>$name=”Myclass”.func_num_args();</p>
<p>$this-&gt;$name();</p>
<p>//Note that $this-&gt;$name() is usually wrong but here</p>
<p>//$name is a string with the name of the method to call.</p>
<p>}</p>
<p>function Myclass1($x) {</p>
<p>code;</p>
<p>}</p>
<p>function Myclass2($x,$y) {</p>
<p>code;</p>
<p>}</p>
<p>}</p>
<p>?&gt;</p>
<p>&nbsp;</p>
<p>With this extra working in the class the use of the class is transparent to the user:</p>
<p>&nbsp;</p>
<p>$obj1=new Myclass(‘1′); //Will call Myclass1</p>
<p>$obj2=new Myclass(‘1′,’2′); //Will call Myclass2</p>
<p>&nbsp;</p>
<p>Sometimes this is very nice.</p>
<p>Polymorphism</p>
<p>&nbsp;</p>
<p>Polymorphism is defined as the ability of an object to determine which method to invoke for an object passed as argument in runtime time. For example if you have a class figure which defines a method draw and derived classes circle and rectangle, where you override the method draw you might have a function which expects an argument x and then call $x-&gt;draw().</p>
<p>&nbsp;</p>
<p>If you have polymorphism the method draw called depends of the type of object you pass to the function.</p>
<p>&nbsp;</p>
<p>Polymorphism is very easy and natural in interpreted languages as PHP (try to imagine a C++ compiler generating code for this case, which method do you call? You don’t know yet which type of object you have! OK, this is not the point).</p>
<p>&nbsp;</p>
<p>So PHP happily supports polymorphism.</p>
<p>&nbsp;</p>
<p>&lt;?php</p>
<p>function niceDrawing($x) {</p>
<p>//Supose this is a method of the class Board.</p>
<p>$x-&gt;draw();</p>
<p>}</p>
<p>$obj=new Circle(3,187);</p>
<p>$obj2=new Rectangle(4,5);</p>
<p>&nbsp;</p>
<p>$board-&gt;niceDrawing($obj); //will call the draw method of Circle.</p>
<p>$board-&gt;niceDrawing($obj2); //will call the draw method of Rectangle.</p>
<p>?&gt;</p>
<p>&nbsp;</p>
<p>Object Oriented Programming in PHP – OOP Programming in PHP</p>
<p>&nbsp;</p>
<p>Some “purists” will say PHP is not truly an object oriented language, which is true. PHP is a hybrid language where you can use OOP and traditional procedural programming.</p>
<p>&nbsp;</p>
<p>For large projects, however, you might want/need to use “pure” OOP in PHP declaring classes and using only objects and classes for your project.</p>
<p>As larger and larger projects emerge the use of OOP may help.</p>
<p>&nbsp;</p>
<p>OOP code is easy to maintain, easy to understand and easy to reuse. Those are the foundations of software engineering. Applying those concepts to web based projects is the key to success in future web sites.</p>
<p>&nbsp;</p>
<p>Advanced OOP Techniques in PHP</p>
<p>&nbsp;</p>
<p>After reviewing the basic concepts of OOP I can show you some more advanced techniques:</p>
<p>&nbsp;</p>
<p>Serialization</p>
<p>&nbsp;</p>
<p>PHP doesn’t support persistent objects; in OOP persistent objects are objects that keep its state and functionality across multiple invocations of the application. This means having the ability to save the object to a file or database and then load the object back. The mechanism is known as serialization.</p>
<p>&nbsp;</p>
<p>PHP has a serialize method which can be called for objects, the serialize method returns a string representation of the object. However serialize saves the data members of the object but not the methods.</p>
<p>In PHP4 if you serialize the object to string $s, then destroy the object, then unserialize the object to $obj you might still access the object methods! I don’t recommend this because:</p>
<p>The documentation doesn’t guarantee this behaviour so in future versions it might not work.</p>
<p>This might lead to ‘illusions’ if you save the serialized version to disk and exit the script. In future runs of the script you can’t unserialize the string to an object and expect the methods to be there because the string representation doesn’t have the methods.</p>
<p>You can serialize associative arrays and arrays to save them to disk too.</p>
<p>&nbsp;</p>
<p>Example:</p>
<p>&lt;?php</p>
<p>$obj=new Classfoo();</p>
<p>$str=serialize($obj);</p>
<p>// Save $str to disk</p>
<p>//…some months later</p>
<p>//Load str from disk</p>
<p>$obj2=unserialize($str)</p>
<p>?&gt;</p>
<p>&nbsp;</p>
<p>You have the data members recovered but not the methods (according to the documentation). This leads to $obj2-&gt;x as the only way to access the data members (you have no methods) so don’t try this at home.</p>
<p>&nbsp;</p>
<p>There’re some ways to fix the problem but I leave it up to you because they are too dirty for this neat article. Full serialization is a feature I’d gladly welcome in PHP.</p>
<p>&nbsp;</p>
<p>Using Classes to Manipulate Stored Data</p>
<p>&nbsp;</p>
<p>One very nice thing about PHP and OOP is that you can easily define classes to manipulate certain things and the call the appropriate classes whenever you want.</p>
<p>&nbsp;</p>
<p>Suppose you have a HTML form where the user selects a product by selecting its product ID, you have the data of the products in a database and you want to display the product, show its price, etc. You have products of different types and the same action might have different meanings for different kind of products.</p>
<p>&nbsp;</p>
<p>For example showing a sound might mean playing it while for some other kind of products might mean to display a picture stored in the database. You might use OOP and PHP to code less and code better:</p>
<p>&nbsp;</p>
<p>Define a class product, define which methods the class should have (example display), then define classes for each type of product which extends the product class (class SoundItem, class ViewableItem, etc.), override the methods you define in product in each of this classes make them do what you want. Name the classes according to the “type” column you store in the database for each product a typical product table might have (id, type, price, description, etc.).</p>
<p>&nbsp;</p>
<p>Then in the processing script you can retrieve the type from the database and instantiate an object of the class named type using:</p>
<p>&nbsp;</p>
<p>&lt;?php</p>
<p>$obj=new $type();</p>
<p>$obj-&gt;action();</p>
<p>?&gt;</p>
<p>&nbsp;</p>
<p>This is a very nice feature of PHP, you might then call the display method of $obj or any other method regardless the type of object you have.</p>
<p>&nbsp;</p>
<p>With this technique you don’t have to touch the processing script when you add a new type of object, just add a class to handle it. This is quite powerful, just define the methods all objects regardless of its type should have, implement them in different ways in different classes and use them for any type of object in the main script, no ifs, no 2 programmers in the same file, eternal happiness.</p>
<p>&nbsp;</p>
<p>Do you agree programming is easy, maintenance is cheaper and reusability is real now?</p>
<p>&nbsp;</p>
<p>If you command a group of programmers it’s easy to divide the tasks, each one might be responsible for a type of object and the class that handles it. Internationalization can be done using this technique, apply the proper class according to a language field selected by the user, etc.</p>
<p>&nbsp;</p>
<p>Object Oriented Programming in PHP – Copying and Cloning</p>
<p>&nbsp;</p>
<p>When you create an object $obj you can copy the object by doing $obj2=$obj, the new object is a copy (not a reference) of $obj so it has the state $obj had in the moment the assignment was made.</p>
<p>&nbsp;</p>
<p>Sometimes you don’t want this you just want to create a new object of the same class as obj, calling the constructor of the new object as if you had used the new statement.</p>
<p>&nbsp;</p>
<p>This can be done in PHP using serialization and a base class that all other classes must extend.</p>
<p>&nbsp;</p>
<p>Entering a Danger Zone</p>
<p>When you serialize an object you get a string which has a certain format, you may investigate this if you are curious. One of the things the string has is the name of the class (nice!), you can extract it using:</p>
<p>&nbsp;</p>
<p>&lt;?php</p>
<p>$herring=serialize($obj);</p>
<p>$vec=explode(‘:’,$herring);</p>
<p>$nam=str_replace(“”&#8221;,”,$vec[2]);</p>
<p>?&gt;</p>
<p>&nbsp;</p>
<p>So suppose you create a class “Universe” and force that all classes must extend universe, you can define a method clone in Universe as:</p>
<p>&nbsp;</p>
<p>&lt;?php</p>
<p>class Universe {</p>
<p>function clone() {</p>
<p>$herring=serialize($this);</p>
<p>$vec=explode(‘:’,$herring);</p>
<p>$nam=str_replace(“”&#8221;,”,$vec[2]);</p>
<p>$ret=new $nam;</p>
<p>return $ret;</p>
<p>}</p>
<p>}</p>
<p>Then:</p>
<p>&nbsp;</p>
<p>$obj=new Something();</p>
<p>//Something extends Universe !!</p>
<p>$other=$obj-&gt;clone();</p>
<p>?&gt;</p>
<p>&nbsp;</p>
<p>What you get is a new object of class Something created the same way as using new; the constructor is called, etc. I don’t know if this is useful for you but the Universe class which knows the name of the derived class is a nice concept to experiment with. The only limit is your imagination.</p>
<p>&nbsp;</p>
<p>Note: I’m using PHP4, some of these examples may not work in PHP3.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iyappan.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iyappan.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iyappan.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iyappan.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iyappan.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iyappan.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iyappan.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iyappan.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iyappan.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iyappan.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iyappan.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iyappan.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iyappan.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iyappan.wordpress.com/103/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=103&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iyappan.wordpress.com/2009/11/03/oops-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/699ecf31da895465ad031bfcb8a44c5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iyappan</media:title>
		</media:content>
	</item>
		<item>
		<title>An Introduction to PHP Classes</title>
		<link>http://iyappan.wordpress.com/2009/11/03/an-introduction-to-php-classes/</link>
		<comments>http://iyappan.wordpress.com/2009/11/03/an-introduction-to-php-classes/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 09:42:35 +0000</pubDate>
		<dc:creator>iyappan</dc:creator>
				<category><![CDATA[OOPS in PHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://iyappan.wordpress.com/?p=101</guid>
		<description><![CDATA[About Object-Oriented Programming Many programming languages are object-oriented. However, the method of defining an object varies from language to language. Some examples of object-oriented languages are: Java JavaScript C++ and finally, PHP Basic Class Programming in PHP In PHP, an object is defined as this: class myObject { //variables and methods go here } Methods [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=101&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>About Object-Oriented Programming</h2>
<p>Many programming languages are object-oriented. However, the method of defining an object varies from language to language. Some examples of object-oriented languages are:</p>
<ul>
<li>Java</li>
<li>JavaScript</li>
<li>C++</li>
<li>and finally, PHP</li>
</ul>
<h2>Basic Class Programming in PHP</h2>
<p>In PHP, an object is defined as this:</p>
<p><code> </code></p>
<pre>class myObject {
    //variables and methods go here
}</pre>
<p>Methods are easy to add to classes. If you wanted to add a function to myObject that returns the current server time, you could do this:<br />
<code> </code></p>
<pre>class myObject{
	function getServerTime() {
		return time();
	}
}</pre>
<p>Easy as that. Defining variables is a little bit trickier. There are many ways to define variables, but we’ll keep it simple for now and use the ‘var’ method.<br />
<code> </code></p>
<pre>class myObject {
        //this is a valid assignment
	var $variable     = 'constant value';

        //this is invalid because it is assigning to a function. This can't be done.
	var $serverTime = time();
}</pre>
<p>To access internal variables, we have to use the <strong>$this</strong> variable. <strong>$this</strong> is a pointer that points internally, so that we can access the variables we just declared. So, we’re going to add a function to ‘myObject’ and access $variable.<br />
<code> </code></p>
<pre>class myObject {
        //this is a valid assignment
	var $variable     = 'Hello World!';
	function GetVariable() {
		//notice how there is no dollar sign $ in front of the variable
		return $this-&gt;variable; //this will return 'Hello World!'
	}
}</pre>
<p>Notice how there is no dollar sign ($) in front of the variable we are pointing to with <strong>$this</strong>. This is also how you call methods internally.</p>
<p>On the last note of basic PHP classes, you will need to know how to create an instance of your class. Once you have created an instance of your class, you can use it in the same way you used ‘this’. To create an instance, use the method:<br />
<code> </code></p>
<pre>$instance = new ClassName();</pre>
<p>This creates a new instance of the class ‘ClassName’. So, an example using everything we’ve learned:<br />
<code> </code></p>
<pre>class myClass {
	var $string = 'Hello World!';
	function ShowString() {
		echo $this-&gt;string;
	}
}
$instance = new myClass();
$instance-&gt;ShowString();</pre>
<p>Also, it is entirely possible to create an instance of a class from a string:</p>
<pre>class MyClass {
	function Exist() {
		echo "My class name is ".get_class($this)."
";
	}
}

$classname = 'MyClass';
$instance = new $classname();
$instance-&gt;Exist();
//this will echo 'My class name is MyClass'
</pre>
<p>That’s about it on a basic level! Now for some more advanced usage of classes.</p>
<h2>Advanced Classes</h2>
<p>Now that you know how to use variables, it’s time to learn about private and public variables. Basically, a private variable can only be accessed internally by the class itself; and a public variable can be accessed by everything. A variable you would want to keep private could be the password of a user class, for example. A public variable could be the title of the page. Public and private variables are very useful.</p>
<p>Here is a class that uses public and private variables:</p>
<p><code> </code></p>
<pre>class myClass {
	private $private_var = "This variable is private! You can't see this!";
	public  $public_var  = "This variable is public! Anyone can see this!";

	//note- you can also use public and private modifiers on functions
	//this is useful because internal functions should be private
	//and external functions could use more than one private function
	//it's good to make a network of public and private methods and variables
	public function PrintPrivate() {
		var_dump($this-&gt;private_var);
	}
}
$instance = new myClass();

//this line will print the contents of $private_var to the screen
//because it is being called internally using an external function of myClass
$instance-&gt;PrintPrivate();

//however, this line will print an error - private variables can't be accessed
//this is because it is being accessed externally
var_dump($instance-&gt;private_var);</pre>
<p>When an instance of a class is created, the method (if it exists) $instance-&gt;__construct(arguments). So, with this knowledge, you should have realised that when calling:<code>$instance = new myClass(arguments)</code> the arguments are sent to the method __contruct inside myClass. This method is called a <strong>constructor</strong>. When an instance is deleted, the class <strong>destructor</strong> is called. The destructor is called when either every variable inside the class has been removed using the PHP function <strong>unset</strong>($variable) or at the end of the script.<br />
<code> </code></p>
<pre>class myClass {
	public $id;
	public function __construct($id) {
		$this-&gt;id = $id;
		echo "Constructed {$this-&gt;id}
";
	}
	public function __destruct() {
		echo "Destructed {$this-&gt;id}
";
	}
}

$count = 0;
$instance = Array();

//this line calls the 'construct' method and creates a new instance
$instance[$count] = new myClass($count);
$count ++;

$instance[$count] = new myClass($count); $count ++;
$instance[$count] = new myClass($count); $count ++;</pre>
<p>This code will echo:<br />
<code> </code></p>
<pre>Constructed 0
Constructed 1
Constructed 2
Destructed 0
Destructed 1
Destructed 2</pre>
<p>You can see that the constructor is called when the instance is created, and that the destructor is called when the script ends.</p>
<p>Now that we understand all of that, we can move on to…</p>
<h2>Static Classes</h2>
<p>So far, the classes have held variables, and have been individual instances. However, if, for example, you wanted a variable that had a set value and applied to all instances of the class, how would you do it? The answer is static variables:<br />
<code> </code></p>
<pre>class myClass {

 //the use of 'static' can be before or after 'public'
 //and it makes the variable global across the class
 static public $variable = 'Hello World!&lt;br/&gt;';

 static public function ShowText() {
 //for static variables, we use self:: instead of $this-&gt;
 echo self::$variable;
 }

 //notice that there is no constructor

}

//there is no need to construct a static class!
myClass::ShowText();
//this will output 'Hello World!'

//however, it is possible to create instances and use static at the same time
$class = Array();
$class[0] = new myClass();

//this is an invalid static function caller:
//$class[0]::ShowText();
//this will result in a parse error!

//this will work:
$class[0]-&gt;ShowText();
//it works because the function can be accessed
//statically and non-statically

$class[1] = new myClass();

//let's try something!
var_dump($class[0]-&gt;variable); echo "&lt;br/&gt;";
var_dump($class[1]-&gt;variable); echo "&lt;br/&gt;";
//these will both echo NULL because using -&gt;
//as a pointer is incorrect!

$class[0]-&gt;variable = 'I\'m class one!';
$class[1]-&gt;variable = 'I\'m class two!';

$class[0]-&gt;ShowText();
$class[1]-&gt;ShowText();
//these will both echo 'Hello World!' because
//using -&gt; as an operator will only change
//the class instance value of $variable
//which previously didn't exist.

//let's try changing it statically and echoing again!
myClass::$variable = 'This text has been changed!&lt;br/&gt;';
$class[0]-&gt;ShowText();
$class[1]-&gt;ShowText();
//these will both echo 'This text has been changed!' because
//the variable has statically been changed
//and this applies to all instances of the class</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iyappan.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iyappan.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iyappan.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iyappan.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iyappan.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iyappan.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iyappan.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iyappan.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iyappan.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iyappan.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iyappan.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iyappan.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iyappan.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iyappan.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=101&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iyappan.wordpress.com/2009/11/03/an-introduction-to-php-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/699ecf31da895465ad031bfcb8a44c5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iyappan</media:title>
		</media:content>
	</item>
		<item>
		<title>“How to” Dual boot Ubuntu and Windows 7 (Ubuntu installed first)</title>
		<link>http://iyappan.wordpress.com/2009/10/29/%e2%80%9chow-to%e2%80%9d-dual-boot-ubuntu-and-windows-7-ubuntu-installed-first/</link>
		<comments>http://iyappan.wordpress.com/2009/10/29/%e2%80%9chow-to%e2%80%9d-dual-boot-ubuntu-and-windows-7-ubuntu-installed-first/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 09:06:47 +0000</pubDate>
		<dc:creator>iyappan</dc:creator>
				<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://iyappan.wordpress.com/?p=98</guid>
		<description><![CDATA[I have recently seen many posts from people trying to dual boot Ubuntu and Windows 7 beta, but not succeeding. So I tried it out myself and found a solution. Index 1. Obtain a copy of Windows7. 2. Partition your disk with gparted. 3. Install Windows7. 4. Re-install Grub. 5. Edit Grub to List Windows [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=98&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have recently seen many posts from people trying to dual boot Ubuntu and Windows 7 beta, but not succeeding. So I tried it out myself and found a solution.<br />
Index<br />
1.	Obtain a copy of Windows7.<br />
2.	Partition your disk with gparted.<br />
3.	Install Windows7.<br />
4.	Re-install Grub.<br />
5.	Edit Grub to List Windows 7.<br />
6.	Have Fun.<br />
__________________________________________________  ________________________________</p>
<p>1.	Obtain a copy of windows 7.</p>
<p>Official Microsoft Link &#8211; No more link your time for the official download is out <img title="Sad" src="http://ubuntuforums.org/images/smilies/icon_sad.gif" border="0" alt="" /></p>
<p>*You can also find a torrent of this but for legal reasons I cannot provide a link. *</p>
<p>2.	Partition your disk</p>
<p>**This does go wrong in some cases, if in doubt back up your valuable data.**</p>
<p>Boot from a Ubuntu live cd or a gparted live cd.<br />
Start up gparted, If ubuntu is on the whole disk you need to re-size it by at least 8 gb for Windows 7. (Make sure windows 7 is on the second partition to make it easier for grub) You will be left with some unallocated space on your hard disk if you want you can partition it to NTFS or you can do it later on the windows install.</p>
<p>3.	Install Windows 7</p>
<p>Follow the on screen instructions, Select the un-partitioned space to format and install windows on, or if you already made it NTFS choose your NTFS partition.</p>
<p>**It will ask for a product key but you have 30 days to do that. Note: Beta keys will work with the RC**</p>
<p>4.	Re-install GRUB</p>
<p>Now you have windows 7 but it has completely eaten your boot loader so you need to re-install grub.<br />
Boot from the ubuntu live cd and go to terminal.<br />
Type in terminal:</p>
<p>&#8220;sudo grub&#8221;<br />
&#8220;grub&gt; find /boot/grub/stage1&#8243;</p>
<p>That should return your Ubuntu partition in the form of (hdX,Y), use that:</p>
<p>grub&gt; root (hdX,Y)<br />
grub&gt; setup (hd0)<br />
grub&gt; quit</p>
<p>(you don’t need to type the grub&gt; bit)</p>
<p>That has re-installed grub but you can no longer see windows7</p>
<p>5.	Edit grub.<br />
Go to terminal from normal ubuntu and type :</p>
<p>“sudo gedit /boot/grub/menu.lst”</p>
<p>A large text file will open and at the bottom leave a line and add this:</p>
<p>title		windows 7 beta (Loader)<br />
root		(hd0,1)<br />
savedefault<br />
makeactive<br />
chainloader	+1</p>
<p>(Do not type this line but if that does not work on re-boot try “hdo,0 or hd0,2” and so on until it works.)</p>
<p>Now that is done you can re-boot  into windows 7 and ubuntu happily <img title="Smile" src="http://ubuntuforums.org/images/smilies/icon_smile.gif" border="0" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iyappan.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iyappan.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iyappan.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iyappan.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iyappan.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iyappan.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iyappan.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iyappan.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iyappan.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iyappan.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iyappan.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iyappan.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iyappan.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iyappan.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=98&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iyappan.wordpress.com/2009/10/29/%e2%80%9chow-to%e2%80%9d-dual-boot-ubuntu-and-windows-7-ubuntu-installed-first/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/699ecf31da895465ad031bfcb8a44c5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iyappan</media:title>
		</media:content>

		<media:content url="http://ubuntuforums.org/images/smilies/icon_sad.gif" medium="image">
			<media:title type="html">Sad</media:title>
		</media:content>

		<media:content url="http://ubuntuforums.org/images/smilies/icon_smile.gif" medium="image">
			<media:title type="html">Smile</media:title>
		</media:content>
	</item>
		<item>
		<title>Why PHP?</title>
		<link>http://iyappan.wordpress.com/2009/08/06/why-php/</link>
		<comments>http://iyappan.wordpress.com/2009/08/06/why-php/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 08:51:25 +0000</pubDate>
		<dc:creator>iyappan</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://iyappan.wordpress.com/?p=95</guid>
		<description><![CDATA[Reply to the query raised to me by many people: The great thing about PHP is that you can do ANYTHING &#8212; really, anything, that can be done on the web by a website. You can do it very, very quickly, and usually with support from existing libraries. And it has been proven to scale [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=95&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Reply to the query raised to me by many people:</p>
<p>The great thing about PHP is that you can do ANYTHING &#8212; really, anything, that can be done on the web by a website. You can do it very, very quickly, and usually with support from existing libraries. And it has been proven to scale horizontally, to the moon.</p>
<p>As for Ruby, it&#8217;s a cute language, I admit. I love the design of Rails (and have been using symfony PHP for a year now because of that.) I haven&#8217;t had a reason to try Python, but I certainly know Java and C# and ASP.NET pretty well. PHP is a much better choice for user-interface-oriented web programming. It simply reduces the amount of effort you need to accomplish your goal, and can still scale.  Why is PHP just an easier way to get things done?</p>
<p>1.  useful, huge ecosystem with amazing sample code</p>
<p>2.  no-theory to get in the way of program logic. PRAGMATISM at it&#8217;s best.</p>
<p>3.  lightning fast edit-compile-test loop (edit-test)</p>
<p>4.  Easy to set up, scale, and migrate between infrastrucure</p>
<p>5.  it doesn&#8217;t put new and idiotic metaphors on top of the web &#8212; the web is it&#8217;s metaphor. (unlike, say, ASP.NET which is godawful)</p>
<p>6. Finding a server that runs PHP is very easy. Most shared hosts don&#8217;t support the other languages and you need to pay more to install it yourself.</p>
<p>6.  super-helpful associative arrays very closely mirror database-style data. I tend to recreate them in every language I use.  There are things that PHP is not great at &#8212; systems administration, realtime services, embedded programming, whatever. But for plain old data-driven website, PHP never loses site of the simple fact &#8212; it&#8217;s just a freakin&#8217; website. Get it done and move on!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iyappan.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iyappan.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iyappan.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iyappan.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iyappan.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iyappan.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iyappan.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iyappan.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iyappan.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iyappan.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iyappan.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iyappan.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iyappan.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iyappan.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iyappan.wordpress.com&amp;blog=1197360&amp;post=95&amp;subd=iyappan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iyappan.wordpress.com/2009/08/06/why-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/699ecf31da895465ad031bfcb8a44c5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iyappan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
