<?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>Webmaster-Source &#187; mistakes</title>
	<atom:link href="https://www.webmaster-source.com/tag/mistakes/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.webmaster-source.com</link>
	<description>Useful Resources For Webmasters</description>
	<lastBuildDate>Thu, 24 Aug 2017 02:01:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>5 PHP Mistakes and How to Avoid Them</title>
		<link>https://www.webmaster-source.com/2009/04/14/5-php-mistakes-and-how-to-avoid-them/</link>
		<comments>https://www.webmaster-source.com/2009/04/14/5-php-mistakes-and-how-to-avoid-them/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 11:07:16 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[mistakes]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=2057</guid>
		<description><![CDATA[PHP is an easy scripting language to learn, but mastering it is a whole other matter. Here are a few common mistakes that beginners, and even experienced PHP developers, might make once in awhile. They&#8217;re not really visible mistakes, such as the ones that would result in an error message. They&#8217;re the sort of thing [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>PHP is an easy scripting language to learn, but mastering it is a whole other matter. Here are a few common mistakes that beginners, and even experienced PHP developers, might make once in awhile.</p>
<p>They&#8217;re not really <em>visible</em> mistakes, such as the ones that would result in an error message. They&#8217;re the sort of thing that might go unnoticed, but could really use fixing.</p>
<ol>
<li><strong>Calling a function more than once unnecessarily.</strong> Suppose you need to, in two places, use the length of a string variable to do something. Don&#8217;t call <code>strlen($var)</code> twice, call it once and save the result to a new variable (name it something like <code>$var_len</code>). Then you can use the variable wherever you need the length. If something will have the same result, only do it once. You&#8217;ll save a few CPU cycles.</li>
<li><strong>SQL Injection vulnerabilities.</strong> SQL Injection is one of the more popular ways for those up to no good to attack a website. Any user-submitted data should be properly escaped before being worked into a database query. Otherwise a seemingly harmless search box or login form could be used as a gateway to your database, opening you up to data theft or deletion. <a href="http://www.tizag.com/mysqlTutorial/mysql-php-sql-injection.php">Read up on SQL Injection and how to counter it.</a></li>
<li><strong>Not encrypting passwords.</strong> Please, <em>never</em> store users&#8217; passwords in plain text. Any software that requires a user to log in with a username and password should use a one-way hash to turn passwords into meaningless gibberish. Users trust you with their login credentials, and they likely use the same ones across multiple sites (despite recommendation otherwise). Don&#8217;t let them be stolen. <a href="http://phpsec.org/articles/2005/password-hashing.html">Password Hashing.</a></li>
<li><strong>Using 302 redirects instead of 301s.</strong> It&#8217;s fairly easy to redirect with PHP&#8217;s header function. However, it doesn&#8217;t do a 301 redirect automatically. It uses a 302 HTTP code, which can cause duplicate content issues with search engines. To do a 301 redirect, you must send a 301 response header before the location header. <a href="http://www.givegoodweb.com/post/72/301-php-header">Sending a 301 “Moved Permanently” Header with PHP.</a></li>
<li><strong>Not using OOP.</strong> The object-oriented approach to programming takes a bit more planning that the procedural approach, but it&#8217;s worth learning if you haven&#8217;t already. It makes for much cleaner code. CSS-Tricks.com has a nice <a href="http://css-tricks.com/php-for-beginners-building-your-first-simple-cms/">tutorial on how to build a basic object-oriented CMS</a>. While not exactly a primer on PHP OOP, it&#8217;s a good hands-on experience. For a ground-up introduction to classes and objects, try Killer PHP&#8217;s <a href="http://www.killerphp.com/tutorials/object-oriented-php/">Object Oriented PHP for Beginners</a>.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2009/04/14/5-php-mistakes-and-how-to-avoid-them/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/


Served from: www.webmaster-source.com @ 2026-06-09 01:13:17 by W3 Total Cache
-->