note 128358 added to control-structures.if
| From: | chielatcomfitechdotnl at main dot php dot net | Date: | Sat, 01 Apr 2023 11:43:46 +0000 |
| Subject: | note 128358 added to control-structures.if | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220316@lists.php.net to get a copy of this message | ||
Note that the IF statement does not always evaluates all expressions. In the next example the second
expression will not be evaluated causing our function not to run. Because the result is already TRUE
and the rest of the expressions are behind the OR operator they will be ignored.
<?php
$a = 0;
if ( true || $a = important_function() ) echo $a;
function important_function(){
// Do very important stuff here.
return 1;
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 77.170.148.243)
----
Manual Page -- https://php.net/manual/en/control-structures.if.php
Edit -- https://main.php.net/note/edit/128358
Del: integrated -- https://main.php.net/note/delete/128358/integrated
Del: useless -- https://main.php.net/note/delete/128358/useless
Del: bad code -- https://main.php.net/note/delete/128358/bad+code
Del: spam -- https://main.php.net/note/delete/128358/spam
Del: non-english -- https://main.php.net/note/delete/128358/non-english
Del: in docs -- https://main.php.net/note/delete/128358/in+docs
Del: other reasons-- https://main.php.net/note/delete/128358
Reject -- https://main.php.net/note/reject/128358
Search -- https://main.php.net/manage/user-notes.php