note 48490 added to language.control-structures

From: Date: Sun, 26 Dec 2004 15:49:48 +0000
Subject: note 48490 added to language.control-structures
Groups: php.notes 
Request: Send a blank email to php-notes+get-82320@lists.php.net to get a copy of this message
For the people that know C: php is lazy when evaluating expressions. That is, as soon as it knows the outcome, it'll stop processing. <?php if ( FALSE && some_function() ) echo "something"; // some_function() will not be called, since php knows that it will never have to execute the if-block ?> This comes in nice in situations like this: <?php if ( file_exists($filename) && filemtime($filename) > time() ) do_something(); // filemtime will never give an file-not-found-error, since php will stop parsing as soon as file_exists returns FALSE ?> ---- Manual Page -- http://www.php.net/manual/en/language.control-structures.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48490 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48490&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48490&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48490&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48490&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48490&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48490&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48490&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82320) next »