In js, you can write this:

rez = num1 || num2; 

And if num1 = false/ null/ undefined then rez = num2

Is there such a thing in php ? A similar entry did not work.

And what is the name of such a record, tell me, I can not google it.

    1 answer 1

    Starting with PHP 5.3, you can use the ternary operator in this version:

     $var = $value ?: "Другое значение"; $var = $value ? $value : "Другое значение"; // Эквивалентно 

    This option is useful when you need to change the value of a variable, only in the case when the variable being checked does not equal true

    And since PHP 7.0, you can:

     $rez = $num1 ?? $num2; $rez = isset($num1) ? $num1 : $num2; // Эквивалентно 

    A source.