Jump to content

[SOLVED] if statement evaluation order


rtpmatt

Recommended Posts

Left to right.

Yes.

 

 

<?php
$a = 1;
$b = 2;

if ($a || $b/0) echo 'true';             // true (as $a evaluates to true).

$a = 0;

if ($a || $b/0) echo 'true';             // div by zero error as second bit needs to be evaluated

?> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.