RE: [PHP] Re: "My truth comes out" [1]

From: Date: Thu, 21 Oct 2010 11:24:55 +0000
Subject: RE: [PHP] Re: "My truth comes out" [1]
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-308924@lists.php.net to get a copy of this message
[snip] > preg_match("/false/i", $string) ? false : true; ,---- | $foo = (strcmp('true', $string) == 0); `---- works as well :) I don't like those kinds of things for this purpose because it takes longer for people new to the code to read and understand it than, say ,---- | (boolean) $string; `---- (which in my case does a pretty meaningless conversion) [/snip] If you are worried that it takes longer for people new to the code to read and understand then add comments! If it is about readability then give them something to read. You could even create a function that is more readable than the 'if' alone; $foo = booleanString($string);

« previous php.general (#308924) next »