<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: PHP: Looking for some Best Practices</title>
	<atom:link href="http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/feed/" rel="self" type="application/rss+xml" />
	<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/</link>
	<description>Internet Gaming, Computer Games, Technology, MMO, and Web 2.0</description>
	<lastBuildDate>Thu, 29 Jul 2010 16:26:58 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2527</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Wed, 11 Feb 2009 15:58:03 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2527</guid>
		<description>Interesting point. Which aspects of modern HTML are you aiming at there? (I&#039;m guessing: CSS, primarily. Personally I&#039;ve found that both the biggest waste of my time with anything HTML and also the biggest timesaver :))</description>
		<content:encoded><![CDATA[<p>Interesting point. Which aspects of modern HTML are you aiming at there? (I&#8217;m guessing: CSS, primarily. Personally I&#8217;ve found that both the biggest waste of my time with anything HTML and also the biggest timesaver :))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Crystall</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2525</link>
		<dc:creator>Andrew Crystall</dc:creator>
		<pubDate>Tue, 10 Feb 2009 23:26:02 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2525</guid>
		<description>The problem with php being reasonably easy to grasp is that modern HTML certainly is not: Unfortunately, that badly undermines the value of languages like php.</description>
		<content:encoded><![CDATA[<p>The problem with php being reasonably easy to grasp is that modern HTML certainly is not: Unfortunately, that badly undermines the value of languages like php.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sidereal</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2514</link>
		<dc:creator>sidereal</dc:creator>
		<pubDate>Fri, 06 Feb 2009 07:57:44 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2514</guid>
		<description>Sounds like a best practice :)</description>
		<content:encoded><![CDATA[<p>Sounds like a best practice :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2508</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Thu, 05 Feb 2009 07:14:11 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2508</guid>
		<description>...forgot to add: and I switch logic flow if not set, each time, so that at any point I can guarantee all vars are set and don&#039;t need to explicitly check them.</description>
		<content:encoded><![CDATA[<p>&#8230;forgot to add: and I switch logic flow if not set, each time, so that at any point I can guarantee all vars are set and don&#8217;t need to explicitly check them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2507</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Thu, 05 Feb 2009 07:12:23 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2507</guid>
		<description>Nod. Where I said I avoid ===, I meant I do things like structure code so that all vars are either isset check at start of execution, or immediately at the time they are set in a way that has a reasonably high chance of failure (e.g. Setting a value by Reading a DB value for a row that may or may not exist).

(one of my practices is to deliberately ignore a lot of error checking that I&#039;d consider mandatory in other langs :) - anything that reduces readability or increases bloat) 

I&#039;m not sure about this but it seems to have worked best for me out of the different structures I&#039;ve tried.</description>
		<content:encoded><![CDATA[<p>Nod. Where I said I avoid ===, I meant I do things like structure code so that all vars are either isset check at start of execution, or immediately at the time they are set in a way that has a reasonably high chance of failure (e.g. Setting a value by Reading a DB value for a row that may or may not exist).</p>
<p>(one of my practices is to deliberately ignore a lot of error checking that I&#8217;d consider mandatory in other langs :) &#8211; anything that reduces readability or increases bloat) </p>
<p>I&#8217;m not sure about this but it seems to have worked best for me out of the different structures I&#8217;ve tried.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sidereal</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2506</link>
		<dc:creator>sidereal</dc:creator>
		<pubDate>Thu, 05 Feb 2009 00:50:24 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2506</guid>
		<description>Doesn&#039;t work for a 0 test.  You&#039;d have to do 

if ($foo == 0 &amp;&amp; isset($foo))

which isn&#039;t much of an improvement</description>
		<content:encoded><![CDATA[<p>Doesn&#8217;t work for a 0 test.  You&#8217;d have to do </p>
<p>if ($foo == 0 &amp;&amp; isset($foo))</p>
<p>which isn&#8217;t much of an improvement</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2505</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Thu, 05 Feb 2009 00:37:58 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2505</guid>
		<description>if( isset( $foo ) ) ?

 :)</description>
		<content:encoded><![CDATA[<p>if( isset( $foo ) ) ?</p>
<p> :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sidereal</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2504</link>
		<dc:creator>sidereal</dc:creator>
		<pubDate>Thu, 05 Feb 2009 00:32:52 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2504</guid>
		<description>adam, I think you&#039;re getting much closer with the &#039;I don&#039;t have to design the whole architecture before I start writing code&#039; angle.  Technically this is more or less true of any language, but I suppose the difference is that scripting languages don&#039;t make you feel guilty about it by reminding you with boilerplate that you should be doing it another way.

I&#039;m not sure avoiding === is a best practice.  I&#039;d say avoiding the things that force you to use it are probably a best practice.  For example, it&#039;s common to initialize all variables to null or false and then do a if (!foo) check later to test for whether it&#039;s ever been set.  Unfortunately, there are all sorts of non-false non-null things that evaluate to false (like 0), so if your variable is intended to be an integer and you need to check for 0 later, you can&#039;t do if (foo == 0) because null and false both match.  You have to do &#039;if (foo === 0)&#039;.  This is just horrifying, both to write and to debug, has no clean solutions, and is a strong argument against taking advantage of the &#039;ease&#039; that weakly typed languages are supposed to provide.  Declaring a datatype and doing some explicit casting is just not that much work.</description>
		<content:encoded><![CDATA[<p>adam, I think you&#8217;re getting much closer with the &#8216;I don&#8217;t have to design the whole architecture before I start writing code&#8217; angle.  Technically this is more or less true of any language, but I suppose the difference is that scripting languages don&#8217;t make you feel guilty about it by reminding you with boilerplate that you should be doing it another way.</p>
<p>I&#8217;m not sure avoiding === is a best practice.  I&#8217;d say avoiding the things that force you to use it are probably a best practice.  For example, it&#8217;s common to initialize all variables to null or false and then do a if (!foo) check later to test for whether it&#8217;s ever been set.  Unfortunately, there are all sorts of non-false non-null things that evaluate to false (like 0), so if your variable is intended to be an integer and you need to check for 0 later, you can&#8217;t do if (foo == 0) because null and false both match.  You have to do &#8216;if (foo === 0)&#8217;.  This is just horrifying, both to write and to debug, has no clean solutions, and is a strong argument against taking advantage of the &#8216;ease&#8217; that weakly typed languages are supposed to provide.  Declaring a datatype and doing some explicit casting is just not that much work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2503</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Wed, 04 Feb 2009 23:14:52 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2503</guid>
		<description>@sidereal

Hmm. Point taken about perl. Although i think that what I said is true in it&#039;s own way - if I&#039;d phrased it better. Certainly Perl was jumped on by non programmers it seemee to me in much the same way that Rexx was, and it was great for whacking out one-liners, and for &quot;writing what you intend to do and it&#039;ll probably &quot;just work&quot; but god help you if it doesn&#039;t and you have to start debugging&quot;.

Perhaps I just meant that perl was a language designed to write code without planning it, which tends to support non programmers since they don&#039;t know how to plan code even if they want to?

Also: sorry about the https, it&#039;s a design flaw in wordpress (admin login is plaintext) they have yet to fix even after many years, and the only workaround is for me to buy a cert and force all users onto https. Only I&#039;m too cheap to buy a cert and this one is in my trust chain so it doesn&#039;t bother me an I keep forgetting about it! When I&#039;m ned feeling rich I&#039;ll pony up :). Until then: I&#039;m sorry.

Also, I had forgotten triple equals.I now automatically design my php so that I never encounter that stufff, mainly because if found nearly all scripting languages have the same or similar problem. I guess it&#039;s a php best practice to avoid it? Thanks!</description>
		<content:encoded><![CDATA[<p>@sidereal</p>
<p>Hmm. Point taken about perl. Although i think that what I said is true in it&#8217;s own way &#8211; if I&#8217;d phrased it better. Certainly Perl was jumped on by non programmers it seemee to me in much the same way that Rexx was, and it was great for whacking out one-liners, and for &#8220;writing what you intend to do and it&#8217;ll probably &#8220;just work&#8221; but god help you if it doesn&#8217;t and you have to start debugging&#8221;.</p>
<p>Perhaps I just meant that perl was a language designed to write code without planning it, which tends to support non programmers since they don&#8217;t know how to plan code even if they want to?</p>
<p>Also: sorry about the https, it&#8217;s a design flaw in wordpress (admin login is plaintext) they have yet to fix even after many years, and the only workaround is for me to buy a cert and force all users onto https. Only I&#8217;m too cheap to buy a cert and this one is in my trust chain so it doesn&#8217;t bother me an I keep forgetting about it! When I&#8217;m ned feeling rich I&#8217;ll pony up :). Until then: I&#8217;m sorry.</p>
<p>Also, I had forgotten triple equals.I now automatically design my php so that I never encounter that stufff, mainly because if found nearly all scripting languages have the same or similar problem. I guess it&#8217;s a php best practice to avoid it? Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2502</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Wed, 04 Feb 2009 23:03:54 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2502</guid>
		<description>@haddad

It has closures? Yikes. How did that slip past me. I feel very stupid for missing it (I looked, but clearly not hard enough; I wasn&#039;t particularly bothered since I rarely use them myself unless it&#039;s a language thwyb makes heavy use of them habitually).

Thanks.

I&#039;ll go look into that some more</description>
		<content:encoded><![CDATA[<p>@haddad</p>
<p>It has closures? Yikes. How did that slip past me. I feel very stupid for missing it (I looked, but clearly not hard enough; I wasn&#8217;t particularly bothered since I rarely use them myself unless it&#8217;s a language thwyb makes heavy use of them habitually).</p>
<p>Thanks.</p>
<p>I&#8217;ll go look into that some more</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sidereal</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2501</link>
		<dc:creator>sidereal</dc:creator>
		<pubDate>Wed, 04 Feb 2009 22:23:53 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2501</guid>
		<description>Aside: Your comment post interface requires https and Chrome hates your cert so it&#039;s throwing up a big, red wall of &#039;do not visit this site&#039;.</description>
		<content:encoded><![CDATA[<p>Aside: Your comment post interface requires https and Chrome hates your cert so it&#8217;s throwing up a big, red wall of &#8216;do not visit this site&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sidereal</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2500</link>
		<dc:creator>sidereal</dc:creator>
		<pubDate>Wed, 04 Feb 2009 22:23:02 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2500</guid>
		<description>Couple of minor quibbles/points.

1) Perl is definitely a scripting language and Perl is absolutely not &#039;intended to be trivial to read and write code; the core language is “easy for a non-programmer to grasp”&#039;.  Which means that the definition of a scripting language needs work.  PHP is a scriptling language that is also fairly approachable, but that&#039;s not implied by the fact that it&#039;s a scripting language.  I think one important aspect of its approachability is that it falls within the mainline 3GL syntax. . meaning it&#039;s imperative, uses braces for block definition, uses the typical iteration operators, etc, etc.  It&#039;s not forcing you to jump into functional syntax or significant whitespace just to do some scripting.

2) &quot;Some things PHP is bad at&quot;

It&#039;s weakly typed, meaning it&#039;s unreliable and requires ginormous hacks like the === operator.

Put this busted syllogism in your interpreter and smoke it:
var_dump(true == &quot;true&quot;); // bool(true);
var_dump(true == 1);      // bool(true);
var_dump(1 == &quot;true&quot;);    // bool(false);

wtf?</description>
		<content:encoded><![CDATA[<p>Couple of minor quibbles/points.</p>
<p>1) Perl is definitely a scripting language and Perl is absolutely not &#8216;intended to be trivial to read and write code; the core language is “easy for a non-programmer to grasp”&#8217;.  Which means that the definition of a scripting language needs work.  PHP is a scriptling language that is also fairly approachable, but that&#8217;s not implied by the fact that it&#8217;s a scripting language.  I think one important aspect of its approachability is that it falls within the mainline 3GL syntax. . meaning it&#8217;s imperative, uses braces for block definition, uses the typical iteration operators, etc, etc.  It&#8217;s not forcing you to jump into functional syntax or significant whitespace just to do some scripting.</p>
<p>2) &#8220;Some things PHP is bad at&#8221;</p>
<p>It&#8217;s weakly typed, meaning it&#8217;s unreliable and requires ginormous hacks like the === operator.</p>
<p>Put this busted syllogism in your interpreter and smoke it:<br />
var_dump(true == &#8220;true&#8221;); // bool(true);<br />
var_dump(true == 1);      // bool(true);<br />
var_dump(1 == &#8220;true&#8221;);    // bool(false);</p>
<p>wtf?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Haddadinator</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2499</link>
		<dc:creator>Haddadinator</dc:creator>
		<pubDate>Wed, 04 Feb 2009 21:03:58 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2499</guid>
		<description>PS, I didnt realize the website was going to directly become a link, so it definitely does not go anywhere.

If you are interested or want to fix the link, i would suggest; http://www.watchhisbeardgrow.com/

It is a recent development of mine and I plan to write more and more...</description>
		<content:encoded><![CDATA[<p>PS, I didnt realize the website was going to directly become a link, so it definitely does not go anywhere.</p>
<p>If you are interested or want to fix the link, i would suggest; <a href="http://www.watchhisbeardgrow.com/" onclick="javascript:pageTracker._trackPageview('/outbound/comment/http://www.watchhisbeardgrow.com/');" rel="nofollow">http://www.watchhisbeardgrow.com/</a></p>
<p>It is a recent development of mine and I plan to write more and more&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Haddadinator</title>
		<link>http://t-machine.org/index.php/2009/02/04/php-looking-for-some-best-practices/comment-page-1/#comment-2498</link>
		<dc:creator>Haddadinator</dc:creator>
		<pubDate>Wed, 04 Feb 2009 21:01:17 +0000</pubDate>
		<guid isPermaLink="false">http://t-machine.org/?p=337#comment-2498</guid>
		<description>Hello Adam. I only have two comments. First of all, I enjoyed reading this. I am a php developer and i KNOW how bad php code can get. I have slapped myself on multiple occasions for the things i have done.

But I wanted to add that php does have closures. They are not often used and I personally have not taken advantage of them yet, but they are there. It is something i plan to investigate soon. (hopefully).

I look forward to reading Part Two.

:)</description>
		<content:encoded><![CDATA[<p>Hello Adam. I only have two comments. First of all, I enjoyed reading this. I am a php developer and i KNOW how bad php code can get. I have slapped myself on multiple occasions for the things i have done.</p>
<p>But I wanted to add that php does have closures. They are not often used and I personally have not taken advantage of them yet, but they are there. It is something i plan to investigate soon. (hopefully).</p>
<p>I look forward to reading Part Two.</p>
<p>:)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
