note 54005 added to language.operators.logical

From: Date: Mon, 20 Jun 2005 19:12:16 +0000
Subject: note 54005 added to language.operators.logical
Groups: php.notes 
Request: Send a blank email to php-notes+get-90708@lists.php.net to get a copy of this message
Discovered a somewhat annoying different between PHP and Perl: <?php function some_function(){ return false; } if ( ! some_function() ) return false; ?> cannot be rewritten as the prettier: <?php function some_function(){ return false; } some_function() or return false; ?> The following will work however: <?php function some_function(){ return false; } some_function() or die(); ?> Can you guess why? Simply, die() is a function and 'return' is a statement (like the difference between print() and echo, sort of). This is really to bad because I find the if(!){} version tired and unreadable, but hey, it's better than if ( some_c_function == 0) { do something }. ---- Manual Page -- http://www.php.net/manual/en/language.operators.logical.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54005 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54005&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54005&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54005&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54005&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54005&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54005&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54005&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90708) next »