php conditional operator not transient -
i having bit of trouble wrapping head around this, thought ask it..
i have code:
$x="string"; var_dump($x==0); //says true var_dump($x==true); //says true var_dump(true==0); //says false
what understand is:
in 1, `string` gets converted number, becomes `0` condition true in 2, `string` value, condition true in 3, `true` not equal `0` condition false
individually make sense, in sequence don't! have heard many people because conditional operator in php not transient
. can explain means, , how make sense of this?
why in world wouldn't make sense? never change value of x, statements dependent on original value of x "string".
you assuming x changed 0 in first var_dump not. merely compared 0/false. statement perform variable change think happening:
var_dump(($x = 0) == 0);
or:
var_dump(($x = false) == 0);