Re: PHP Editor - which to use?

From: Date: Wed, 24 Sep 2003 14:25:37 +0000
Subject: Re: PHP Editor - which to use?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-163745@lists.php.net to get a copy of this message
* Thus wrote Jon Haworth (jon@laughing-buddha.net): > Hi, > > > Good coder will understand this at a glimpse: > > [snip horrible code] > > > if($pos_params!=false) um... you rewrote that, his code was: if( $pos_params != false ) > > Assuming it's a boolean, $pos_params is *already* true or false, so testing > it like this is pretty much pointless. It makes more sense (and is much more > readable IMHO) to do something like this: > > if ($pos_params) { > // something > } Also, i'd like to add, that even though these code examples will work it maybe a little missleading. Assuming where this $pos_params came from is strpos(), $pos_params can be false or 0. The condition that is being tested doesn't really let the code reader know that. In fact, there is a bug with both versions, if the $pos_params is the first character (value of 0) then we the back_url_params is going to get lost. So in theory the condition *should* be if ( $pos_params !== false) Ok, I've evaluated all this code way too much now :) Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#163745) next »