In my last project I had to specify a value, normally I use the following statement:
<?php
$true = 1;
$false = 0;
$hasAccess = $true ? 1 : 0;
print $hasAccess;
?>
but this works to:
<?php
$true = 1;
$false = 0;
$hasAccess = $true || $false;
print $hasAccess;
?>
Why?
Update: I know what a OR / || is and what I have to expect from it. But I haven’t seen this possibility any time before.
Because 0 is automaticly casted to (bool)false, and anything else (bool)true.
So what you are basicly saying is:
$hasaccess = true OR false;See also:
http://php.net/manual/en/language.types.boolean.php
http://php.net/manual/en/language.operators.logical.php