How can I do this in php? or or and return a boolean;

var a = 0, b = 3, с = a||b; alert(с); // 3 

I.e

 a ? a : b -> a||b 

    1 answer 1

    Recently rose similar

     // PHP <= 5.2 $c=$a or $c=$b; // "||" не прокатит, для наглядности ($c = $a) or ($c = $b) // PHP 5.3+ $c = $a ?: $b; 
    • one
      Thank you, just thank you) - Oleg
    • 2
      Note that in JS, the operation " || " is not "logical or", but a function that returns the first argument if it is NOT null, NaN, undefined, 0 , otherwise, the second argument is timka_s
    • @timka_s is not a function. - Oleg