<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: PHP Speed and Security: The Code Optimization Phase</title>
	<link>http://foliovision.com/2007/11/07/phpp-speed-security-code-optimization/</link>
	<description>Making the web work for you</description>
	<pubDate>Sun, 20 Jul 2008 11:13:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.3</generator>

	<item>
		<title>By: peter</title>
		<link>http://foliovision.com/2007/11/07/phpp-speed-security-code-optimization/#comment-3378</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Mon, 28 Jan 2008 09:57:27 +0000</pubDate>
		<guid>http://foliovision.com/2007/11/07/phpp-speed-security-code-optimization/#comment-3378</guid>
		<description>2: The speed of both echo and print is fast and in comparisson to another functions that are commonly used in almost every PHP script, their speed difference doesn't matter that much.

16: Closing of database connection is actually a serious discussion. For instance Microsoft encourage programmers to close connection to database after every pack of queries. This applies for .NET but databases are the same for .NET and PHP, so this is maybe a subject for another blog.

17: It is very, VERY bad practise to write string without quotes. Every strict programming language will throw error on this one. Everybody should avoid using this type of coding. (I know my words are strong, but proper coding practices are very important)

18: Error messages surely create a lot of overhead and good code should actually deal with all posible errors within itself. Exception handling was not introduced to PHP from the begginig, so PHP is not built to cope only with exceptions. Hopefully PHP crew will enhance their error handling in future, so more stable and reliable coding will be possible.</description>
		<content:encoded><![CDATA[<p>2: The speed of both echo and print is fast and in comparisson to another functions that are commonly used in almost every PHP script, their speed difference doesn&#8217;t matter that much.</p>
<p>16: Closing of database connection is actually a serious discussion. For instance Microsoft encourage programmers to close connection to database after every pack of queries. This applies for .NET but databases are the same for .NET and PHP, so this is maybe a subject for another blog.</p>
<p>17: It is very, VERY bad practise to write string without quotes. Every strict programming language will throw error on this one. Everybody should avoid using this type of coding. (I know my words are strong, but proper coding practices are very important)</p>
<p>18: Error messages surely create a lot of overhead and good code should actually deal with all posible errors within itself. Exception handling was not introduced to PHP from the begginig, so PHP is not built to cope only with exceptions. Hopefully PHP crew will enhance their error handling in future, so more stable and reliable coding will be possible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alec</title>
		<link>http://foliovision.com/2007/11/07/phpp-speed-security-code-optimization/#comment-3308</link>
		<dc:creator>alec</dc:creator>
		<pubDate>Fri, 25 Jan 2008 20:12:35 +0000</pubDate>
		<guid>http://foliovision.com/2007/11/07/phpp-speed-security-code-optimization/#comment-3308</guid>
		<description>Could you test this James, for PHP?

A few real world number for how many ticks it takes to handle an error in PHP versus a clean execution...

The issue with PHP is that one uses it to automate a lot of repetitive small tasks. Any error is like an echo chamber. But would be interestin to know exactly the cost.</description>
		<content:encoded><![CDATA[<p>Could you test this James, for PHP?</p>
<p>A few real world number for how many ticks it takes to handle an error in PHP versus a clean execution&#8230;</p>
<p>The issue with PHP is that one uses it to automate a lot of repetitive small tasks. Any error is like an echo chamber. But would be interestin to know exactly the cost.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Dunmore</title>
		<link>http://foliovision.com/2007/11/07/phpp-speed-security-code-optimization/#comment-3306</link>
		<dc:creator>James Dunmore</dc:creator>
		<pubDate>Fri, 25 Jan 2008 19:49:20 +0000</pubDate>
		<guid>http://foliovision.com/2007/11/07/phpp-speed-security-code-optimization/#comment-3306</guid>
		<description>I agree - writing the code correctly in the first place is definitely the most effective; although dealing with errors in a smart way is also good.

I remember from when I used to do Java, discussions about (as an abstract example) is it more efficient to check if a variable is not zero, or just place the code in a try catch block (and catch the divide by zero error) - it would be interesting to see if similar principles apply to PHP5? 

(obviously you can see that the discussion would go on, as the debate ranges from should you purposely write code that would throw an error, or is throwing an error an acceptable coding practice!? I don't think I ever concluded that one!) 

Cheers, James.</description>
		<content:encoded><![CDATA[<p>I agree - writing the code correctly in the first place is definitely the most effective; although dealing with errors in a smart way is also good.</p>
<p>I remember from when I used to do Java, discussions about (as an abstract example) is it more efficient to check if a variable is not zero, or just place the code in a try catch block (and catch the divide by zero error) - it would be interesting to see if similar principles apply to PHP5? </p>
<p>(obviously you can see that the discussion would go on, as the debate ranges from should you purposely write code that would throw an error, or is throwing an error an acceptable coding practice!? I don&#8217;t think I ever concluded that one!) </p>
<p>Cheers, James.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alec</title>
		<link>http://foliovision.com/2007/11/07/phpp-speed-security-code-optimization/#comment-3305</link>
		<dc:creator>alec</dc:creator>
		<pubDate>Fri, 25 Jan 2008 19:34:21 +0000</pubDate>
		<guid>http://foliovision.com/2007/11/07/phpp-speed-security-code-optimization/#comment-3305</guid>
		<description>Thanks for the tips James.

What I mean by "Error messages are expensive" is that each error message generates a lot of overhead with log writing and recovery. It's like a sound room with an echo.

If you get the code right in the first place, you'll be able to use the processor for processing and not for error recovery.

In general, PHP, particularly PHP5 is becoming a much more efficient language with time so a lot of these issues will be resolved with better coding practice and stricter coding guidelines.</description>
		<content:encoded><![CDATA[<p>Thanks for the tips James.</p>
<p>What I mean by &#8220;Error messages are expensive&#8221; is that each error message generates a lot of overhead with log writing and recovery. It&#8217;s like a sound room with an echo.</p>
<p>If you get the code right in the first place, you&#8217;ll be able to use the processor for processing and not for error recovery.</p>
<p>In general, PHP, particularly PHP5 is becoming a much more efficient language with time so a lot of these issues will be resolved with better coding practice and stricter coding guidelines.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Dunmore</title>
		<link>http://foliovision.com/2007/11/07/phpp-speed-security-code-optimization/#comment-3304</link>
		<dc:creator>James Dunmore</dc:creator>
		<pubDate>Fri, 25 Jan 2008 16:58:19 +0000</pubDate>
		<guid>http://foliovision.com/2007/11/07/phpp-speed-security-code-optimization/#comment-3304</guid>
		<description>Interesting stuff and some great tips, but I believe not all is valid.

For example, number 2 "echo is faster than print" whilst this may be fractionally true (it seriously does not make a huge difference, in fact, I believe echo will become an alias of print in later PHP versions) there are better considerations like using single quotes rather then double quotes on a string. 
The use of double quotes is mentioned in the other article you link to, however, it says "Of course you can only do this when you don't need to have variables in the string." but doesn't mention that concatenation is much faster than trying to put variables inside a double quote string. HEREDOC also has a terrible overhead.

16. Close your database connections when you're done with them - again, I'm not sure of the usefulness of this comment, you will end up with developers creating modules that close the DB connection only for another module to reopen, surely encouraging the use of a singleton is much more efficient.

17 $row[’id’] is 7 times faster than $row[id]
USING $row[id] IS WRONG
Please see http://uk3.php.net/manual/en/language.types.array.php

I'm also interested in this:
18. "Error messages are expensive"
Do you mean displaying an error message is expensive, or having a script that doesn't work is expensive?</description>
		<content:encoded><![CDATA[<p>Interesting stuff and some great tips, but I believe not all is valid.</p>
<p>For example, number 2 &#8220;echo is faster than print&#8221; whilst this may be fractionally true (it seriously does not make a huge difference, in fact, I believe echo will become an alias of print in later PHP versions) there are better considerations like using single quotes rather then double quotes on a string.<br />
The use of double quotes is mentioned in the other article you link to, however, it says &#8220;Of course you can only do this when you don&#8217;t need to have variables in the string.&#8221; but doesn&#8217;t mention that concatenation is much faster than trying to put variables inside a double quote string. HEREDOC also has a terrible overhead.</p>
<p>16. Close your database connections when you&#8217;re done with them - again, I&#8217;m not sure of the usefulness of this comment, you will end up with developers creating modules that close the DB connection only for another module to reopen, surely encouraging the use of a singleton is much more efficient.</p>
<p>17 $row[’id’] is 7 times faster than $row[id]<br />
USING $row[id] IS WRONG<br />
Please see <a href="http://uk3.php.net/manual/en/language.types.array.php" rel="nofollow">http://uk3.php.net/manual/en/language.types.array.php</a></p>
<p>I&#8217;m also interested in this:<br />
18. &#8220;Error messages are expensive&#8221;<br />
Do you mean displaying an error message is expensive, or having a script that doesn&#8217;t work is expensive?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
