note 56647 deleted from language.operators.logical by colder
| From: | colder@php.net | Date: | Tue, 01 May 2007 05:44:38 +0000 |
| Subject: | note 56647 deleted from language.operators.logical by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126008@lists.php.net to get a copy of this message | ||
Note Submitter: test at hto dot com
----
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;
?>