note 54005 deleted from language.operators.logical by colder

From: Date: Fri, 20 Apr 2007 15:37:32 +0000
Subject: note 54005 deleted from language.operators.logical by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-125691@lists.php.net to get a copy of this message
Note Submitter: ironmo67 at yahoo dot com ---- 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 }.

« previous php.notes (#125691) next »