note 76110 added to function.is-null

From: Date: Sat, 30 Jun 2007 22:45:59 +0000
Subject: note 76110 added to function.is-null
Groups: php.notes 
Request: Send a blank email to php-notes+get-128115@lists.php.net to get a copy of this message
Just a friendly note, people. The following is considered horrible code: <?php function myFunc () { if (foo || bar) { return true; } else { return false; } } ?> (or variations thereof) Instead, use the following syntax and you won't be the laughing stock of fellow developers: <?php function myFunc () { return (foo || bar); } ?> The reason this works is because the condition is already a boolean, and there is no reason not to return it. I've heard people argue that this is less readable, but those people were idiots, so deal with it. ---- Server IP: 193.190.198.20 Probable Submitter: 81.164.163.247 ---- Manual Page -- http://www.php.net/manual/en/function.is-null.php Edit -- https://master.php.net/note/edit/76110 Del: integrated -- https://master.php.net/note/delete/76110/integrated Del: useless -- https://master.php.net/note/delete/76110/useless Del: bad code -- https://master.php.net/note/delete/76110/bad+code Del: spam -- https://master.php.net/note/delete/76110/spam Del: non-english -- https://master.php.net/note/delete/76110/non-english Del: in docs -- https://master.php.net/note/delete/76110/in+docs Del: other reasons-- https://master.php.net/note/delete/76110 Reject -- https://master.php.net/note/reject/76110 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128115) next »