Will an If Statement Stop Checking if the first OR condition is met in PHP? -
i want try , make code efficient possible , ive read
if($process == true) will process faster calls function. i.e
if(count($total) == 100) so if had or inside if , first condition simple boolean check , turned out true second part of condition still checked anyway?
for example
$process = true; if($process == true || count($total) == 100) would count function still called though process true , enough make condition pass.
php has indeed mechanic named short-circuit: http://php.net/manual/en/language.operators.logical.php#example-140
if first operand of logical or true, second part isn't evaluated, , function isn't called.
since comparing variable boolean faster calling function in php, mechanic can optimize, never forget premature optimisation root of evil.
Comments
Post a Comment