note 54174 deleted from language.operators.logical by nlopess
| From: | nlopess@php.net | Date: | Fri, 02 Jun 2006 08:56:20 +0000 |
| Subject: | note 54174 deleted from language.operators.logical by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-112914@lists.php.net to get a copy of this message | ||
Note Submitter: Serafina
----
Because the OR shorthand for an if block can produce more
readable code with less typing, it is tempting to produce functions that will return FALSE on
failure or some other data type on success. Like mysql_connect, which "Returns a MySQL link
identifier on success, or FALSE on failure."
The novice php php developer should avoid creating functions which might produce a FALSE on failure
and an integer on success, if there is any chance that the integer might be zero.
<?php
blah blah blah;
$i = give_me_liberty() or die("FATAL DB ERROR!");
blah blah blah;
?>
If the function give_me_liberty() occasionally completes successfully and produces a zero, the
result could be perplexing.