<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Anmol Sheth</title>
	<atom:link href="http://anmolsheth.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://anmolsheth.com</link>
	<description></description>
	<lastBuildDate>Sat, 09 Apr 2011 11:51:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>15 Wonderfully Creative Uses for PHP</title>
		<link>http://anmolsheth.com/creative-uses-php/</link>
		<comments>http://anmolsheth.com/creative-uses-php/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 11:33:59 +0000</pubDate>
		<dc:creator>Anmol</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[creative]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://anmolsheth.com/?p=275</guid>
		<description><![CDATA[1. E-Commerce E-commerce is one of the major uses for PHP. From a small business level to an enterprise level, businesses are always looking to create additional streams of revenue online. If you know how to integrate existing e-commerce solutions or build your own from scratch, this gives you a distinct advantage with your clients. [...]]]></description>
			<content:encoded><![CDATA[<h3>1. E-Commerce</h3>
<p>E-commerce is one of the major uses for PHP. From a small business level to an enterprise level, businesses are always looking to create additional streams of revenue online. If you know how to integrate existing e-commerce solutions or build your own from scratch, this gives you a distinct advantage with your clients.</p>
<h3>Advanced Coders</h3>
<p>If you want to build your own shopping cart application, you can either code the entire application from scratch or implement a PHP framework. If you are an intermediate to advanced PHP coder, I personally recommend using a framework such as <a href="http://codeigniter.com/">CodeIgniter</a> or <a href="http://cakephp.org/">CakePHP</a>. CakePHP has a <a href="http://bakery.cakephp.org/">bakery section</a> with readily available source code for e-commerce applications. For instance, you can integrate Paypal with your site using ready-made scripts. CodeIgniter has a <a href="http://codeigniter.com/user_guide/">user guide</a> and a few tutorials to get you up and running quickly. Both of these frameworks have extensive documentation on how to create web applications from the ground up; which one you use is really a matter of personal preference.</p>
<h3>Beginners</h3>
<p>If you are new to PHP, or you just know some basic PHP programming, I would suggest using an existing e-commerce solution. Some of the available options are:</p>
<ul>
<li><a href="http://www.magentocommerce.com/">Magento</a></li>
<li><a href="http://www.zen-cart.com/">Zen Cart</a></li>
<li><a href="http://www.shopify.com/">Shopify</a></li>
</ul>
<p>While I understand that each of these solutions has its own quirks, it might be easier to spend a few days with the documentation or a tutorial than to learn PHP from the ground up. It really depends on how much time you are willing to invest in tackling e-commerce.</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-01.png" border="0" alt="" /></div>
<h3>2. Project Management Tools</h3>
<p>For both freelancers and web development firms alike, project management is an important aspect of your business. Your clients need a resource to be able to check the progress of the work and provide feedback. Ideally, with a good project management system in place, your clients will be thoroughly pleased with the end result.</p>
<p>There are several excellent web-based project management tools on the market today. If you can afford to use a subscription service, I would highly recommend <a href="http://www.basecamphq.com/">Basecamp</a>. Although Basecamp was written in Ruby on Rails, it is an excellent advertisement for effective, streamlined project management solutions. For those of us who do not necessarily need a subscription-based product, you can build your own!</p>
<p>Building your own project management tool from the ground up will require a bit of in-depth PHP and some Javascript knowledge. The most important aspects of the application are <a href="http://us3.php.net/manual/en/security.php">security</a>, <a href="http://us3.php.net/manual/en/ref.datetime.php">time-tracking</a>, <a href="http://www.w3schools.com/html/html_forms.asp">collaborative to-do lists</a>, <a href="http://us3.php.net/manual/en/features.file-upload.php">file sharing</a>, a message board, and a live preview of the website &#8211; which could simply be a link to an index.html page. Of course, you can add to this list or remove features as you like. The takeaway point here is that you can learn a lot about PHP by creating this application and your customers will be happy to see their project take shape. Showing you how to get started on your own project management tool is beyond the scope of this article, but I hope I have given you a good basis to start generating ideas!</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-02.png" border="0" alt="" /></div>
<h3>3. Graphical User Interface</h3>
<p>For those of you who are up to the challenge, you can extend your PHP installation to create desktop applications. This one is a challenge because it requires some extensive knowledge of PHP and it might also be easier to create desktop applications in other programming languages. If PHP is your favorite programming language, then you can use some of these PHP extensions to get you started creating <acronym title="Graphical User Interface">GUI</acronym> applications.</p>
<ul>
<li><a href="http://gtk.php.net/">PHP GTK</a> &#8211; This extension is a popular open source that implements the GIMP toolkit</li>
<li><a href="http://www.zzee.com/php-gui/">ZZEE PHP GUI</a> &#8211; A paid solution that allows you to turn your PHP scripts into Windows applications</li>
</ul>
<p>The main advantage of creating your own PHP GUI&#8217;s is that you will learn a great deal about the language itself!</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-03.gif" border="0" alt="" /></div>
<h3>4. Building an Online Community</h3>
<p>Whether your website is about business, entertainment, or products and services, internet users need to feel connected to the product or message. For example, if you develop web applications, a forum where your customers can discuss issues might be a good idea. As a user, if I have a question and I need support right away, a hotline or an e-mail form is often insufficient. With an online community, your visitors can help solve each other&#8217;s product-related issues, and even answer technical questions. You still have to provide some level of after-sales support, but a community can effectively decrease your workload and provide useful feedback.</p>
<p>You can build your own PHP-driven online community, or choose from widely available scripts that you can implement into your website. Again, if you plan to build your own forum from scratch, I do recommend the use of a PHP Framework. CodeIgniter, for example, has classes and helpers to take care of the most routine tasks you can think of. Beyond that, you can use several different forum building tools. Some popular ones include:</p>
<ul>
<li><a href="http://www.phpbb.com/">php BB</a></li>
<li><a href="http://www.vbulletin.com/">vBulletin</a></li>
<li><a href="http://punbb.informer.com/">Pun BB</a></li>
</ul>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-04.png" border="0" alt="" /></div>
<h3>5. Developing Facebook Applications</h3>
<p>You can integrate Facebook with your website using PHP. If you have developed Facebook applications using another language or you would like to get started with PHP, the <a href="http://wiki.developers.facebook.com/index.php/PHP">Facebook developer&#8217;s wiki</a> can help you to get started. The developer&#8217;s wiki explains the Facebook PHP client library and provides detailed instructions on how to install and use the files included in the library. This is certainly worth a look if you are interested in programming for the Facebook platform. For Facebook users interested in the back-end of the platform, this would be a natural step.</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-05.png" border="0" alt="" /></div>
<h3>6. Generating PDF Files</h3>
<p>The <acronym title="Portable Document Format">PDF</acronym> format is Adobe&#8217;s proprietary file type for document exchange. Using a library called PDFLib, you can generate PDF files with PHP. This library is already included with PHP5; to access it, you need to uncomment the appropriate lines in your PHP configuration file. An example of why creating PDF files might come in useful is, if you were building an online invoicing application and you wanted to output an HTML-generated invoice in PDF format. You can then send the invoice via e-mail or print a copy of it to your client.</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-06.gif" border="0" alt="" /></div>
<h3>7. Parsing XML Files</h3>
<p>PHP allows you to parse <acronym title="eXtensible Markup Language">XML</acronym> files. Parsing XML is an important feature of PHP 5 because not all browsers can output the contents of an XML file; so you can create a parser in PHP to facilitate this process. Using XML is important for RSS feeds, and also for data storage and rendering data on different devices &#8211; for example, cell phones use an implementation of XML called WML (Wireless Markup Language). Working with XML files in PHP is similar to handling the opening, closing, and reading of a file. The steps involved are creating an XML parser, setting functions to handle your opening and closing XML tags, opening the file for reading, reading the file incrementally and then closing it.</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-07.png" border="0" alt="" /></div>
<h3>8. Mailing Lists</h3>
<p>You can write your own script to send e-mail newsletters to your client, or use a ready-made script. PHP mailing lists are an excellent way to keep your clients informed about your services and products, holidays, vacations, and general announcements. Anything your clients need to know can be included in your automated newsletter. The PHP online documentation explains <a href="http://us3.php.net/manual/en/function.mail.php">PHP mailing functions</a> in more detail. There are also  scripts you can download and install on your website:</p>
<ul>
<li><a href="http://www.phplist.com/">PHP list</a></li>
</ul>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-08.gif" border="0" alt="" /></div>
<h3>9. Image Processing and Generation</h3>
<p>Using the GD library with PHP, you can do more than just output HTML to the browser! You can output images in different file types including jpeg, png, and gif. This feature of PHP is useful because it allows you to create thumbnail pictures, add watermarks, resize and crop images, and even create a photo gallery!</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-09.gif" border="0" alt="" />Image by &#8220;<a href="http://blog.calevans.com/">Cal Evans</a>&#8220;</div>
<h3>10. Create Graphs and Charts</h3>
<p>Do you need visual representations of numbers on your site? PHP can create graphs and charts too! Using <a href="http://pear.veggerby.dk/">Image_Graph</a>, you can create up to fourteen different types of charts including pie charts, bar graphs, impulse, dot/scatter, step, candlestick, box &amp; whisker, radar. This is incredibly useful for e-commerce websites or websites where you need to present graphical data in a concise manner. the Image_Graph website has more detail on how you can get started!</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-10.gif" border="0" alt="" /></div>
<h3>11. Content Management Systems</h3>
<p>One of the most popular uses of PHP is creating or using Content Management System. A good CMS allows your clients to update their website and add content without any in-depth knowledge of HTML and CSS. A good Content Management System should be user friendly, extensible, produce clean <acronym title="Uniform Resource Locator">URL</acronym>&#8216;s, and be search engine friendly among other things. There are several online resources you can use to assist you with coding your own CMS from scratch, or you can use one of the widely available free or commercial solutions listed below:</p>
<ul>
<li><a href="http://www.drupal.org/">Drupal</a></li>
<li><a href="http://www.wordpress.org/">WordPress</a></li>
<li><a href="http://www.joomla.org/">Joomla</a></li>
</ul>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-11.png" border="0" alt="" /></div>
<h3>12. Create a PHP Photo Gallery</h3>
<p>By simply using PHP&#8217;s file handling functions, you can create your own photo gallery! you begin by placing your photos in a single directory, you then use PHP&#8217;s <a href="http://www.php.net/manual/en/book.exif.php">exif</a> function to get header information about the photo and output a thumbnail version of it. The process is as straightforward as it sounds and its also a great way to present your photos!</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-12.png" border="0" alt="" /></div>
<h3>13. Create Dynamic Website Templates</h3>
<p>Using PHP, you can make it easier to add pages and elements to your websites dynamically. You begin by creating the HTML page and splitting it into the header, main content, and footer sections. Add the .php extension to your subsequent pages and use server-side Includes for the header and footer for each new page. You can also have dynamic sidebars and top navigation sections. As a matter of fact, the more &#8220;templated&#8221; your site is, the easier it is to update the content.</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-13.png" border="0" alt="" /></div>
<h3>14. Create WordPress Plugins</h3>
<p>If you have done any work with WordPress, you will know that it is a highly flexible blogging system that you can use to do just about anything from e-commerce to content management. With that being said, if you know some PHP and you delve into the <a href="http://codex.wordpress.org/Plugins">WordPress Codex</a>, you have everything you need to begin plugin development. If you need novel ideas for creating plugins, they even have a section where users post their <a href="http://wordpress.org/extend/ideas/">plugin ideas</a>.</p>
<p><a href="http://net.tutsplus.com/videos/screencasts/a-crash-course-in-wordpress-plugin-development/">Watch a screencast that teaches how to build your first WordPress plugin. </a></p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-14.png" border="0" alt="" /></div>
<h3>15. Creating Flash</h3>
<p>The use of Flash in websites is a contentious issue to say the least! But there is nothing wrong with having Flash elements in certain places on your website; PHP can help with this! To these files you would use the <a href="http://us3.php.net/manual/en/intro.ming.php">Ming library</a> to create Flash files in .swf format. With this library, you can generate movies, text, and even animations in Flash!</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/310_phpTricks/images/php-15.jpg" border="0" alt="" /></div>
<p>You&#8217;ve just learned fifteen creative uses of PHP which you can use to improve your website or just have fun with &#8211; enjoy them all! Any I missed?</p>
<p>Main Source:-</p>
<p>http://net.tutsplus.com/tutorials/php/15-wonderfully-creative-uses-for-php/</p>
]]></content:encoded>
			<wfw:commentRss>http://anmolsheth.com/creative-uses-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>30+ PHP Best Practices for Beginners – Basix</title>
		<link>http://anmolsheth.com/phpbasix/</link>
		<comments>http://anmolsheth.com/phpbasix/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 11:27:11 +0000</pubDate>
		<dc:creator>Anmol</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Basic practice]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://anmolsheth.com/?p=268</guid>
		<description><![CDATA[1. Befriend the PHP Manual If you&#8217;re new to PHP, then it&#8217;s time to get acquainted with the awesomeness that is the PHP manual. The PHP manual is incredibly thorough and has truly helpful comments following each article. Before asking questions or trying to figure out an issue on your own, save some time and [...]]]></description>
			<content:encoded><![CDATA[<h3>1. Befriend the PHP Manual</h3>
<p>If you&#8217;re new to PHP, then it&#8217;s time to get acquainted with the awesomeness that is the <a href="http://www.php.net/manual/en/index.php">PHP manual</a>. The PHP manual is incredibly thorough and has truly helpful comments following each article. Before asking questions or trying to figure out an issue on your own, save some time and just head straight to the manual. Odds are the answer to your question is already nestled in a helpful article at the PHP.net site.</p>
<h3>2. Turn on Error Reporting</h3>
<p><a href="http://www.php.net/manual/en/function.error-reporting.php">Error reporting in PHP</a> is very helpful. You&#8217;ll find bugs in your code that you might not have spotted earlier, as not all bugs keep the application from working. There are different levels of strictness in the reporting that you can use, but E_ALL will show you the most errors, critical and warnings alike.</p>
<p>Once you&#8217;ve gotten your application ready for production, you&#8217;ll want to turn off error reporting, or your visitors will see strange errors that they don&#8217;t understand.</p>
<h3>3. Try an IDE</h3>
<p>IDE&#8217;s (Integrated Development Environments) are helpful tools for any developer. While they&#8217;re not for everyone, an IDE definitely has its place. IDE&#8217;s provide tools like</p>
<ul>
<li>syntax highlighting</li>
<li>code completion</li>
<li>error warnings</li>
<li>refactoring (reworking)</li>
</ul>
<p>And many other features. There are <a href="http://www.smashingmagazine.com/2009/02/11/the-big-php-ides-test-why-use-oneand-which-to-choose/">plenty of great IDEs</a> out there that support PHP.</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/407_php/3-IDE.png" alt="Try an IDE" /></div>
<h3>4. Try a PHP Framework</h3>
<p>You can learn a lot about PHP just by experimenting with PHP frameworks. Frameworks like <a href="http://cakephp.org/">CakePHP</a> or <a href="http://codeigniter.com/">CodeIgniter</a> allow you to quickly create PHP applications, without having to be an expert with PHP. In a sense, they&#8217;re almost like PHP training wheels that show you what a PHP application should look like, and show you valuable programming concepts (like separating the logic from the design, etc.).</p>
<blockquote><p><em>Rebuttal: I personally wouldn&#8217;t recommend that beginners use a framework. Learn the fundamentals first. <img src='http://anmolsheth.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </em></p></blockquote>
<h3>5. Learn the DRY Approach</h3>
<p>DRY stands for <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself">Don&#8217;t Repeat Yourself</a>, and it&#8217;s a valuable programming concept, no matter what the language. DRY programming, as the name implies, is ensuring that you don&#8217;t write redundant code. Here&#8217;s an example from <a href="http://reinholdweber.com/php/php-programmers-evolution-scribble/">Reinhold Weber</a>:</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/407_php/DRY.png" alt="Learn the DRY approach" /></div>
<p>This code&#8230;</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">copy to clipboard</a><a onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">print</a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">?</a></div>
</div>
<ol>
<li><span><span>$mysql</span><span> = mysql_connect(</span><span>&#8216;localhost&#8217;</span><span>, </span><span>&#8216;reinhold&#8217;</span><span>, </span><span>&#8216;secret_hash&#8217;</span><span>); </span></span></li>
<li><span>mysql_select_db(<span>&#8216;wordpress&#8217;</span><span>) </span><span>or</span><span> </span><span>die</span><span>(</span><span>&#8220;cannot select DB&#8221;</span><span>); </span></span></li>
</ol>
</div>
<pre style="display: none;">$mysql = mysql_connect('localhost', 'reinhold', 'secret_hash');
mysql_select_db('wordpress') or die("cannot select DB");</pre>
<p>now with the DRY approach:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">copy to clipboard</a><a onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">print</a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">?</a></div>
</div>
<ol>
<li><span><span>$db_host</span><span> = </span><span>&#8216;localhost&#8217;</span><span>; </span></span></li>
<li><span><span>$db_user</span><span> = </span><span>&#8216;reinhold&#8217;</span><span>; </span></span></li>
<li><span><span>$db_password</span><span> = </span><span>&#8216;secret_hash&#8217;</span><span>; </span></span></li>
<li><span><span>$db_database</span><span> = </span><span>&#8216;wordpress&#8217;</span><span>; </span></span></li>
<li><span> </span></li>
<li><span><span>$mysql</span><span> = mysql_connect(</span><span>$db_host</span><span>, </span><span>$db_user</span><span>, </span><span>$db_password</span><span>); </span></span></li>
<li><span>mysql_select_db(<span>$db_database</span><span>); </span></span></li>
</ol>
</div>
<pre style="display: none;">$db_host = 'localhost';
$db_user = 'reinhold';
$db_password = 'secret_hash';
$db_database = 'wordpress';

$mysql = mysql_connect($db_host, $db_user, $db_password);
mysql_select_db($db_database);</pre>
<p>You can read more about the DRY programming principle <a href="http://www.artima.com/intv/dry.html">here</a> and <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself">here</a>.</p>
<h3>6. Indent Code and Use White Space for Readability</h3>
<p>If you don&#8217;t use indentations and white space in your code, the result looks like a Jackson Pollack painting. Ensure that your code is readable and easy to search because you&#8217;ll most definitely be making changes in the future. IDEs and advanced text editors can add indentation automatically.</p>
<h3>7. &#8220;Tier&#8221; your Code</h3>
<p>Tiering your applications is nothing more than separating the different components of the code into different parts. This allows you to easily change your code in the future. NETTUTS writer Jason Lengstorf has written an excellent article on <a href="http://net.tutsplus.com/tutorials/php/add-power-to-your-php-with-multi-tiered-applications/">how to tier your PHP applications</a> for easier maintenance.</p>
<h3>8. Always Use &lt;?php ?&gt;</h3>
<p>Often times programmers try to take shortcuts when declaring PHP. Here are a few common ones:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">copy to clipboard</a><a onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">print</a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">?</a></div>
</div>
<ol>
<li><span><span>&lt;? </span></span></li>
<li><span> <span>echo</span><span> </span><span>&#8220;Hello world&#8221;</span><span>; </span></span></li>
<li><span>?&gt; </span></li>
<li><span> </span></li>
<li><span>&lt;?=<span>&#8220;Hello world&#8221;</span><span>; ?&gt; </span></span></li>
<li><span> </span></li>
<li><span>&lt;% <span>echo</span><span> </span><span>&#8220;Hello world&#8221;</span><span>; %&gt; </span></span></li>
</ol>
</div>
<pre style="display: none;">&lt;?
    echo "Hello world";
?&gt;

&lt;?="Hello world"; ?&gt;

&lt;% echo "Hello world"; %&gt;</pre>
<p>While these do save a few characters, all of these methods are depreciated and unofficial. Stick with the standard &lt;?php ?&gt; as it will be guaranteed to be supported in all future versions.</p>
<h3>9. Use Meaningful, Consistent Naming Conventions</h3>
<p>Naming this isn&#8217;t just for your own good. There&#8217;s nothing worse than trying to find your way through some other programmer&#8217;s nonsensical naming conventions. Help yourself <em>and</em> others by using names that make sense for your classes and functions.</p>
<h3>10. Comment, Comment, Comment</h3>
<p>Aside from using white space and indentations to separate the code, you&#8217;ll also want to use inline comments to annotate your code. You&#8217;ll thank yourself later when you&#8217;re needing to go back and find something in the code, or if you just can&#8217;t remember what a certain function did. It&#8217;s also useful for anyone else who needs to look over your code.</p>
<h3>11. Install MAMP/WAMP</h3>
<p>MySQL is the most popular type of database to use with PHP (though it&#8217;s not the only one). If you&#8217;re wanting to set up a local environment to develop and test your PHP applications on your computer, look into installing <a href="http://www.mamp.info/en/index.html">MAMP</a> (Mac) or <a href="http://www.wampserver.com/en/">WAMP</a> (Windows). Installing MySQL on your own computer can be a tedious process, and both of these software packages are drop-in installs of MySQL. Clean and simple.</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/407_php/mamp.png" alt="Install MAMP/WAMP" /></div>
<h3>12. Give your Scripts Limits</h3>
<p>Putting a time limit on your PHP scripts is a very critical thing. There are times when your scripts will fail, and when they do, you&#8217;ll want to use the <a href="http://php.net/manual/en/function.set-time-limit.php">set_time_limit</a> function to avoid infinite loops and database connection timeouts. The set_time_limit puts a time limit on the maximum number of seconds a script will run (the default is 30). After that time period, a fatal error is thrown.</p>
<h3>13. Use Objects (or OOP)</h3>
<p>Object-oriented programming (OOP) uses objects to represent parts of the application. Not only is OOP a way to break your code into separate, logical sections, it also reduces code repetition and makes it much easier to modify in the future. If you&#8217;re wanting to learn more, DevArticles has a great write-up on <a href="http://www.devarticles.com/c/a/PHP/Object-Oriented-Programming-in-PHP/">object-oriented programming with PHP</a>.</p>
<h3>14. Know the Difference Between Single and Double Quotes</h3>
<p>It is more efficient to use <em>single</em> quotes in strings as the parser doesn&#8217;t have to sift through the code to look for escaped characters and other things that double quotes allow. Always try to use single quotes whenever possible.</p>
<blockquote><p><em>Rebuttal: Actually, that&#8217;s not necessarily true. Benchmark tests show that, when testing strings without variables, there are definite performance benefits to using <strong>double quotes</strong>. </em></p></blockquote>
<h3>15. Don&#8217;t Put phpinfo() in your Webroot</h3>
<p><a href="http://us2.php.net/phpinfo">Phpinfo</a> is a beautiful thing. By simply creating a PHP file that has</p>
<div>
<ol>
<li><span><span>&lt;?php phpinfo(); ?&gt; </span></span></li>
</ol>
</div>
<pre style="display: none;">	&lt;?php phpinfo(); ?&gt;</pre>
<p>and dropping it onto the sever somewhere, you can instantly learn everything about your server environment. However, a lot of beginners will place a file containing phpinfo() in the webroot of the server. This is a really insecure practice, and if prying eyes gain access, it could potentially spell doom for your server. Make sure phpinfo() is in a secure spot, and as an extra measure, delete it once you&#8217;re done.</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/407_php/phpinfo.png" alt="don't put phpinfo() in your web root" /></div>
<h3>16. Never, Ever Trust Your Users</h3>
<p>If your application has places for user input, you should always assume that they&#8217;re going to try to input naughty code. (We&#8217;re not implying that your users are bad people. It&#8217;s just a good mindset.) A great way to keep your site hacker-free is to always initialize your variables to safeguard your site from <a href="http://ha.ckers.org/xss.html">XSS attacks</a>. PHP.net has an example of a <a href="http://talks.php.net/show/php-best-practices/19">properly secured form</a> with initialized variables:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">copy to clipboard</a><a onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">print</a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">?</a></div>
</div>
<ol>
<li><span><span>&lt;?php </span></span></li>
<li><span><span>if</span><span> (correct_user(</span><span>$_POST</span><span>[</span><span>'user'</span><span>], </span><span>$_POST</span><span>[</span><span>'password'</span><span>]) { </span></span></li>
<li><span> <span>$login</span><span> = true; </span></span></li>
<li><span>} </span></li>
<li><span> </span></li>
<li><span><span>if</span><span> (</span><span>$login</span><span>) { </span></span></li>
<li><span> forward_to_secure_environment(); </span></li>
<li><span>} </span></li>
<li><span>?&gt; </span></li>
</ol>
</div>
<pre style="display: none;">	&lt;?php
	if (correct_user($_POST['user'], $_POST['password']) {
	    $login = true;
	}

	if ($login) {
	    forward_to_secure_environment();
	}
	?&gt;</pre>
<h3>17. Store Passwords with Encryption</h3>
<p>Many PHP beginners often plunk sensitive data like passwords into the database without applying any encryption. Consider using <a href="http://us3.php.net/md5">MD5</a> to encrypt passwords before you put them into the database.</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">copy to clipboard</a><a onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">print</a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">?</a></div>
</div>
<ol>
<li><span><span>echo</span><span> md5(</span><span>&#8216;myPassword&#8217;</span><span>); </span><span>// renders - deb1536f480475f7d593219aa1afd74c</span><span> </span></span></li>
</ol>
</div>
<pre style="display: none;">echo md5('myPassword'); // renders - deb1536f480475f7d593219aa1afd74c</pre>
<blockquote><p><em>Rebuttal: </em> Keep in mind, however, that MD5 hashes have long since been compromised. They&#8217;re absolutely more secure than not, but, with the use of an enormous &#8220;rainbow table,&#8221; hackers can cross reference your hash. To add even more security, consider adding a salt as well. A salt is basically an additional set of characters that you append to the user&#8217;s string.</p></blockquote>
<h3>18. Use Database Visualization Design Tools</h3>
<p>If you&#8217;re finding it difficult to plan and modify databases for your PHP applications, you might look into using a database visualization tool. MySQL users can work with <a href="http://fabforce.net/dbdesigner4/">DBDesigner</a> and <a href="http://dev.mysql.com/workbench/">MySQL Workbench</a> to visually design your databases.</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/407_php/workbench.png" alt="use database visualization design tools" /></div>
<h3>19. Use Output Buffering</h3>
<p>Output buffering is a simple way to greatly improve the performance and speed of your PHP script. Without output buffering, your script will show the HTML on the page as it&#8217;s processed &#8211; in pieces. Adding output buffering allows the PHP to store the HTML as a variable and send it to the browser in one chunk.</p>
<p>To enable output buffering, simply add ob_start() like so at the top of the file.</p>
<blockquote><p>Rebuttal: Though not required, it&#8217;s generally considered to be a good practice to go ahead and append the &#8220;ob_end_flush();&#8221; function as well to the bottom of the document. P.S. Want to compress the HTML as well? Simply replace &#8220;ob_start();&#8221; with &#8220;ob_start(&#8216;ob_gzhandler&#8217;)&#8221;;</p>
<p>Refer to this <a href="http://dev-tips.com/featured/output-buffering-for-web-developers-a-beginners-guide">Dev-tips article</a> for more information.</p></blockquote>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">copy to clipboard</a><a onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">print</a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">?</a></div>
</div>
<ol>
<li><span><span>&lt;!DOCTYPE html&gt; </span></span></li>
<li><span>&lt;?php ob_start(<span>&#8216;ob_gzhandler&#8217;</span><span>); ?&gt; </span></span></li>
<li><span>&lt;html lang=<span>&#8220;en&#8221;</span><span>&gt; </span></span></li>
<li><span>&lt;head&gt; </span></li>
<li><span> &lt;meta http-equiv=<span>&#8220;Content-Type&#8221;</span><span> content=</span><span>&#8220;text/html; charset=utf-8&#8243;</span><span>&gt; </span></span></li>
<li><span> &lt;title&gt;untitled&lt;/title&gt; </span></li>
<li><span>&lt;/head&gt; </span></li>
<li><span>&lt;body&gt; </span></li>
<li><span> </span></li>
<li><span>&lt;/body&gt; </span></li>
<li><span>&lt;/html&gt; </span></li>
<li><span>&lt;?php ob_end_flush(); ?&gt; </span></li>
</ol>
</div>
<pre style="display: none;">&lt;!DOCTYPE html&gt;
&lt;?php ob_start('ob_gzhandler'); ?&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
	&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
	&lt;title&gt;untitled&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;
&lt;?php ob_end_flush(); ?&gt;</pre>
<h3>20. Protect your Script From SQL Injection</h3>
<p>If you don&#8217;t escape your characters used in SQL strings, your code is vulnerable to SQL injections. You can avoid this by either using the <a href="http://us3.php.net/mysql_real_escape_string">mysql_real_escape_string</a>, or by using prepared statements.</p>
<p>Here&#8217;s an example of mysql_real_escape_string in action:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">copy to clipboard</a><a onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">print</a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">?</a></div>
</div>
<ol>
<li><span><span>$username</span><span> = mysql_real_escape_string( </span><span>$GET</span><span>[</span><span>'username'</span><span>] ); </span></span></li>
</ol>
</div>
<pre style="display: none;">$username = mysql_real_escape_string( $GET['username'] );</pre>
<p>and a prepared statement:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">copy to clipboard</a><a onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">print</a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">?</a></div>
</div>
<ol>
<li><span><span>$id</span><span> = </span><span>$_GET</span><span>[</span><span>'id'</span><span>]; </span></span></li>
<li><span><span>$statement</span><span> = </span><span>$connection</span><span>-&gt;prepare( </span><span>&#8220;SELECT * FROM tbl_members WHERE id = ?&#8221;</span><span> ); </span></span></li>
<li><span><span>$statement</span><span>-&gt;bind_param( </span><span>&#8220;i&#8221;</span><span>, </span><span>$id</span><span> ); </span></span></li>
<li><span><span>$statement</span><span>-&gt;execute(); </span></span></li>
</ol>
</div>
<pre style="display: none;">	$id = $_GET['id'];
	$statement = $connection-&gt;prepare( "SELECT * FROM tbl_members WHERE id = ?" );
	$statement-&gt;bind_param( "i", $id );
	$statement-&gt;execute();</pre>
<blockquote><p><em>By using prepared statements, we never embed the user&#8217;s inputted data directly into our query. Instead, we use the &#8220;bind_param&#8221; method to bind the values (and escaping) to the query. Much safer, and, notably, faster when executing multiple CRUD statements at once.</em></p></blockquote>
<p>Read more on <a href="http://net.tutsplus.com/tutorials/php/5-helpful-tips-for-creating-secure-php-applications/">creating secure PHP applications</a> at Nettuts.</p>
<h3>21. Try ORM</h3>
<p>If you&#8217;re writing object-oriented PHP, then you can use the nifty object relational mapping (ORM). ORM allows you to convert data between relational databases and object-oriented programming languages. In short: ORM allows you to work with databases the same way that you work with classes and objects in PHP.</p>
<p>There are plenty of ORM libraries for PHP like <a href="http://propel.phpdb.org/trac/">Propel</a>, and ORM is built into PHP frameworks like <a href="http://cakephp.org/">CakePHP</a>.</p>
<h3>22. Cache Database-Driven Pages</h3>
<p>Caching database-driven PHP pages is an excellent idea to improve the load and performance of your script. It&#8217;s really not all that difficult to create and retrieve static files of content with the help of our good friend ob_start(). Here&#8217;s an example taken <a href="http://www.snipe.net/2009/03/quick-and-dirty-php-caching/">from Snipe.net</a>:</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">copy to clipboard</a><a onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">print</a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">?</a></div>
</div>
<ol>
<li><span><span>// TOP of your script</span><span> </span></span></li>
<li><span><span>$cachefile</span><span> = </span><span>&#8216;cache/&#8217;</span><span>.</span><span>basename</span><span>(</span><span>$_SERVER</span><span>[</span><span>'SCRIPT_URI'</span><span>]); </span></span></li>
<li><span><span>$cachetime</span><span> = 120 * 60; </span><span>// 2 hours</span><span> </span></span></li>
<li><span><span>// Serve from the cache if it is younger than $cachetime</span><span> </span></span></li>
<li><span><span>if</span><span> (</span><span>file_exists</span><span>(</span><span>$cachefile</span><span>) &amp;&amp; (time() - </span><span>$cachetime</span><span> &lt; </span><span>filemtime</span><span>(</span><span>$cachefile</span><span>))) { </span></span></li>
<li><span><span>include</span><span>(</span><span>$cachefile</span><span>); </span></span></li>
<li><span><span>echo</span><span> </span><span>&#8220;&lt;!&#8211; Cached &#8221;</span><span>.</span><span>date</span><span>(</span><span>&#8216;jS F Y H:i&#8217;</span><span>, </span><span>filemtime</span><span>(</span><span>$cachefile</span><span>)).</span><span>&#8220; &#8211;&gt;&#8221;</span><span>; </span></span></li>
<li><span><span>exit</span><span>; </span></span></li>
<li><span>} </span></li>
<li><span>ob_start(); <span>// start the output buffer</span><span> </span></span></li>
<li><span><span>// Your normal PHP script and HTML content here</span><span> </span></span></li>
<li><span><span>// BOTTOM of your script</span><span> </span></span></li>
<li><span><span>$fp</span><span> = </span><span>fopen</span><span>(</span><span>$cachefile</span><span>, </span><span>&#8216;w&#8217;</span><span>); </span><span>// open the cache file for writing</span><span> </span></span></li>
<li><span>fwrite(<span>$fp</span><span>, ob_get_contents()); </span><span>// save the contents of output buffer to the file</span><span> </span></span></li>
<li><span>fclose(<span>$fp</span><span>); </span><span>// close the file</span><span> </span></span></li>
<li><span>ob_end_flush(); <span>// Send the output to the browser</span><span> </span></span></li>
</ol>
</div>
<pre style="display: none;">	// TOP of your script
	$cachefile = 'cache/'.basename($_SERVER['SCRIPT_URI']);
	$cachetime = 120 * 60; // 2 hours
	// Serve from the cache if it is younger than $cachetime
	if (file_exists($cachefile) &amp;&amp; (time() - $cachetime &lt; filemtime($cachefile))) {
	include($cachefile);
	echo "&lt;!-- Cached ".date('jS F Y H:i', filemtime($cachefile))." --&gt;";
	exit;
	}
	ob_start(); // start the output buffer
	// Your normal PHP script and HTML content here
	// BOTTOM of your script
	$fp = fopen($cachefile, 'w'); // open the cache file for writing
	fwrite($fp, ob_get_contents()); // save the contents of output buffer to the file
	fclose($fp); // close the file
	ob_end_flush(); // Send the output to the browser</pre>
<p>This bit of code will use a cached version of a page that is less than 2 hours old.</p>
<h3>23. Use a Caching System</h3>
<p>If you&#8217;re wanting a more robust caching system, there are a few caching scripts for PHP that might be more complete than the above example.</p>
<ul>
<li><a href="http://www.danga.com/memcached/">Memcached</a></li>
<li><a href="http://us.php.net/manual/en/intro.apc.php">APC</a></li>
<li><a href="http://xcache.lighttpd.net/">XCache</a></li>
<li><a href="http://files.zend.com/help/Zend-Platform/zend_cache_api.htm">Zend Cache</a></li>
<li><a href="http://www.eaccelerator.net/">eAccelerator</a></li>
</ul>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/407_php/memcached.png" alt="use a caching system" /></div>
<h3>24. Validate Cookie Data</h3>
<p>Cookie data, like any data passed on the Web, can be harmful. You can validate cookie data with either the <a href="http://us3.php.net/manual/en/function.htmlspecialchars.php">htmlspecialchars()</a> or <a href="http://us3.php.net/mysql_real_escape_string">mysql_real_escape_string()</a>.</p>
<h3>25. Use Static File Caching Systems</h3>
<p>Aside from using database caching systems like Memcached, you might also want to try a templating system to increase performance in your PHP applications. <a href="http://www.smarty.net/">Smarty</a> is a robust templating system has caching built into it.</p>
<h3>26. Profile your Code</h3>
<p>Profiling your code with a tool like <a href="http://xdebug.org/">xdebug</a> can help you to quickly spot bottlenecks and other potential problems in your PHP code. Some IDEs like <a href="http://netbeans.org/">Netbeans</a> have PHP profiling capabilities as well.</p>
<h3>27. Code to a Standard</h3>
<p>Once you&#8217;ve gotten the ropes of PHP down, you can start learning about coding to a standard. There are differences between standards out there (say <a href="http://framework.zend.com/manual/en/coding-standard.html">Zend</a> and <a href="http://pear.php.net/manual/en/standards.php">Pear</a>), and finding one and sticking with it will help with the consistency of your coding in the long run.</p>
<h3>28. Keep Functions Outside of Loops</h3>
<p>You take a hit of performance when you include functions inside of loops. The larger the loop that you have, the longer the execution time will take. Take the extra time and line of code and place the function outside of the loop.</p>
<blockquote><p><em> Editor&#8217;s Note: Think of it this way. Try to remove as many operations from the loop as possible. Do you really need to create that variable for every iteration of the loop? Do you really need to create the function each time? Of course not. <img src='http://anmolsheth.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </em></p></blockquote>
<h3>29. Don&#8217;t Copy Extra Variables</h3>
<p>Some people like to try and make their code more appealing by copying predefined variables to smaller-named variables. This is redundant and could potentially double the memory of your script. Google Code has bad and good examples of variable usage:</p>
<p>Bad</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">copy to clipboard</a><a onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">print</a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">?</a></div>
</div>
<ol>
<li><span><span>$description</span><span> = </span><span>strip_tags</span><span>(</span><span>$_POST</span><span>[</span><span>'description'</span><span>]); </span></span></li>
<li><span><span>echo</span><span> </span><span>$description</span><span>; </span></span></li>
</ol>
</div>
<pre style="display: none;">	$description = strip_tags($_POST['description']);
	echo $description;</pre>
<p>Good</p>
<div>
<div>
<div><a onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">view plain</a><a onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">copy to clipboard</a><a onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">print</a><a onclick="dp.sh.Toolbar.Command('About',this);return false;" href="http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/#">?</a></div>
</div>
<ol>
<li><span><span>echo</span><span> </span><span>strip_tags</span><span>(</span><span>$_POST</span><span>[</span><span>'description'</span><span>]); </span></span></li>
</ol>
</div>
<pre style="display: none;">	echo strip_tags($_POST['description']);</pre>
<blockquote><p><em> Rebuttal: In reference to the comment about &#8220;doubling the memory,&#8221; this actually is a common misconception. PHP implements &#8220;copy-on-write&#8221; memory management. This basically means that you can assign a value to as many variables as you like without having to worry about the data actually <em>being</em> copied. While it&#8217;s arguable that the &#8220;Good&#8221; example exemplified above might make for cleaner code, I highly doubt that it&#8217;s any quicker. </em></p></blockquote>
<h3>30. Upgrade to the Latest Version of PHP</h3>
<p>While it seems like a common sense thing, many people don&#8217;t upgrade PHP as often as they should. There are lots of performance increases between PHP 4 and PHP 5. Check your server to make sure you&#8217;re up to date.</p>
<h3>31. Reduce the Number of Database Queries</h3>
<p>Any way that you can cut back on the number of database queries, the better your PHP script will perform. There are tools like <a href="http://en.wikipedia.org/wiki/Strace">Stace</a> (Unix) and <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx">Process Explorer</a> (Windows) that allow you to find redundant processes and how you might combine them.</p>
<div><img style="display: inline;" src="http://nettuts.s3.amazonaws.com/407_php/strace.png" alt="Reduce the number of database queries" /></div>
<h3>32. Don&#8217;t be Afraid to Ask for Help</h3>
<p>It&#8217;s only human nature to want to hide the fact that we don&#8217;t know much about a certain topic. Nobody likes being a n00b! But how are we going to learn without asking? Feel free to use forums, IRC, <a href="http://www.stackoverflow.com/">StackOverflow</a> to ask more seasoned PHP developers questions. The PHP website has a page on <a href="http://www.php.net/support.php">getting PHP help</a>.</p>
<p>Have any rebuttals of your own? I&#8217;m sure you do! Let&#8217;s start the debate.</p>
<p><strong>MAIN SOURCE:&#8212;&#8212;&#8212;-</strong></p>
<p>http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/</p>
]]></content:encoded>
			<wfw:commentRss>http://anmolsheth.com/phpbasix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google&#8217;s New Real Time Search</title>
		<link>http://anmolsheth.com/googles-new-real-time-search/</link>
		<comments>http://anmolsheth.com/googles-new-real-time-search/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 01:20:23 +0000</pubDate>
		<dc:creator>Anmol</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://anmolsheth.com/?p=256</guid>
		<description><![CDATA[search results to life with a dynamic stream of real-time content from across the web. Now, immediately after conducting a search, you can see live updates from people on popular sites like Twitter and FriendFeed, as well as headlines from news and blog posts published just seconds before. When they are relevant, They&#8217;ll rank these [...]]]></description>
			<content:encoded><![CDATA[<p>search results to life with a dynamic stream of real-time content from across the web. Now, immediately after conducting a search, you can see live updates from people on popular sites like Twitter and FriendFeed, as well as headlines from news and blog posts published just seconds before. When they are relevant, They&#8217;ll rank these latest results to show the freshest information right on the search results page.</p>
<p>I tried this out myself..its fantastic</p>
]]></content:encoded>
			<wfw:commentRss>http://anmolsheth.com/googles-new-real-time-search/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Project 365</title>
		<link>http://anmolsheth.com/project-365/</link>
		<comments>http://anmolsheth.com/project-365/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 00:05:18 +0000</pubDate>
		<dc:creator>Anmol</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://anmolsheth.com/?p=238</guid>
		<description><![CDATA[Project 365 
My world around 365]]></description>
			<content:encoded><![CDATA[<p>I am resuming my Project 365 and hope it will work fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://anmolsheth.com/project-365/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web is not in world, &#8220;World is in Web&#8221;</title>
		<link>http://anmolsheth.com/1000s-of-images-in-my-mind/</link>
		<comments>http://anmolsheth.com/1000s-of-images-in-my-mind/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 17:33:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Articles]]></category>

		<guid isPermaLink="false">http://freshface.cz/lcp/wp/?p=59</guid>
		<description><![CDATA[In 21st century, Web is booming every business, personal ideas and sharing thoughts.]]></description>
			<content:encoded><![CDATA[<p>In 21st century, Web is booming every business, personal ideas and sharing thoughts.</p>
]]></content:encoded>
			<wfw:commentRss>http://anmolsheth.com/1000s-of-images-in-my-mind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My New Ride</title>
		<link>http://anmolsheth.com/my-new-ride/</link>
		<comments>http://anmolsheth.com/my-new-ride/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 16:52:46 +0000</pubDate>
		<dc:creator>Anmol</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://freshface.cz/lcp/wp/?p=37</guid>
		<description><![CDATA[Its my new ride in web development world as a professional. My vision on my new site is to share knowledge about web development and photography. I&#8217;ll try to share my knowledge or creative ideas by blog&#8217;s help&#8230; Even if you have new ideas or thoughts you guys can send me e-mail or you can [...]]]></description>
			<content:encoded><![CDATA[<p>Its my new ride in web development world as a professional. My vision on my new site is to share knowledge about web development and photography. I&#8217;ll try to share my knowledge or creative ideas by <strong><a href="http://anmolsheth.com/category/blog/" target="_self">blog&#8217;s</a></strong> help&#8230;</p>
<p>Even if you have new ideas or thoughts you guys can send me e-mail or you can start new topic in reply. I will try to reply your e-mails ASAP.</p>
]]></content:encoded>
			<wfw:commentRss>http://anmolsheth.com/my-new-ride/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Indian Celebration Pics</title>
		<link>http://anmolsheth.com/my-new-digital-camera-joko-vfx-5000/</link>
		<comments>http://anmolsheth.com/my-new-digital-camera-joko-vfx-5000/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 13:31:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://freshface.cz/lcp/wp/?p=111</guid>
		<description><![CDATA[This is puja pics at Vishal Shah&#8217;s Home]]></description>
			<content:encoded><![CDATA[<p>This is puja pics at Vishal Shah&#8217;s Home</p>
]]></content:encoded>
			<wfw:commentRss>http://anmolsheth.com/my-new-digital-camera-joko-vfx-5000/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Am I Proposing Myself ???</title>
		<link>http://anmolsheth.com/amiproposing/</link>
		<comments>http://anmolsheth.com/amiproposing/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 17:32:08 +0000</pubDate>
		<dc:creator>Anmol</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://freshface.cz/lcp/wp/?p=57</guid>
		<description><![CDATA[Me and Vishal been to Westminster, London for Photography (Night) Walkabout. I love the way light comes on my face without any flash (We don&#8217;t need it, Street light was there).. It was last time when I used my Nikon D-40.]]></description>
			<content:encoded><![CDATA[<p>Me and Vishal been to Westminster, London for Photography (Night) Walkabout.</p>
<p>I love the way light comes on my face without any flash (We don&#8217;t need it, Street light was there)..</p>
<p>It was last time when I used my Nikon D-40.</p>
]]></content:encoded>
			<wfw:commentRss>http://anmolsheth.com/amiproposing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Indian Tradition</title>
		<link>http://anmolsheth.com/my-new-buddy-is-a-dj/</link>
		<comments>http://anmolsheth.com/my-new-buddy-is-a-dj/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 16:01:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://freshface.cz/lcp/wp/?p=47</guid>
		<description><![CDATA[Indian Culture explains the way of communicating with god (virtually though) Its around 4-5 hours of  process and trying to tell GOD, Please help me&#8230;Loving This Way..]]></description>
			<content:encoded><![CDATA[<p>Indian Culture explains the way of communicating with god (virtually though)</p>
<p>Its around 4-5 hours of  process and trying to tell GOD, Please help me&#8230;Loving This Way..</p>
]]></content:encoded>
			<wfw:commentRss>http://anmolsheth.com/my-new-buddy-is-a-dj/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pure And Clear Diamond</title>
		<link>http://anmolsheth.com/pure-and-clear-diamond/</link>
		<comments>http://anmolsheth.com/pure-and-clear-diamond/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 16:55:52 +0000</pubDate>
		<dc:creator>Anmol</dc:creator>
				<category><![CDATA[Photoshop]]></category>

		<guid isPermaLink="false">http://freshface.cz/lcp/wp/?p=39</guid>
		<description><![CDATA[It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using &#8216;Content here, content here&#8217;, making it look like readable English. Many [...]]]></description>
			<content:encoded><![CDATA[<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has<span id="more-39"></span> a more-or-less normal distribution of letters, as opposed to using &#8216;Content here, content here&#8217;, making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for &#8216;lorem ipsum&#8217; will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
]]></content:encoded>
			<wfw:commentRss>http://anmolsheth.com/pure-and-clear-diamond/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

