note 76839 added to language.control-structures

From: Date: Wed, 01 Aug 2007 18:59:59 +0000
Subject: note 76839 added to language.control-structures
Groups: php.notes 
Request: Send a blank email to php-notes+get-129110@lists.php.net to get a copy of this message
As mentioned below, PHP stops evaluating expressions as soon as the result is clear. So a nice shortcut for if-statements is logical AND -- if the left expression is false, then the right expression can’t possibly change the result anymore, so it’s not executed. <?php /* defines MYAPP_DIR if not already defined */ if (!defined('MYAPP_DIR')) { define('MYAPP_DIR', dirname(getcwd())); } /* the same */ !defined('MYAPP_DIR') && define('MYAPP_DIR', dirname(getcwd())); ?> ---- Server IP: 217.13.201.10 Probable Submitter: 172.182.40.166 ---- Manual Page -- http://www.php.net/manual/en/language.control-structures.php Edit -- https://master.php.net/note/edit/76839 Del: integrated -- https://master.php.net/note/delete/76839/integrated Del: useless -- https://master.php.net/note/delete/76839/useless Del: bad code -- https://master.php.net/note/delete/76839/bad+code Del: spam -- https://master.php.net/note/delete/76839/spam Del: non-english -- https://master.php.net/note/delete/76839/non-english Del: in docs -- https://master.php.net/note/delete/76839/in+docs Del: other reasons-- https://master.php.net/note/delete/76839 Reject -- https://master.php.net/note/reject/76839 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129110) next »