Pyh.conf’25: a new PHP conference for the Russian-speaking community

Voting

: two minus one?
(Example: nine)

The Note You're Voting On

dumitru at floringabriel dot com
8 years ago
In addition to what Lawrence said about assigning a default value, one can now use the Null Coalescing Operator (PHP 7). Hence when we want to assign a default value we can write:

$a = ($fruit ?? 'apple');
//assigns the $fruit variable content to $a if the $fruit variable exists or has a value that is not NULL, or assigns the value 'apple' to $a if the $fruit variable doesn't exists or it contains the NULL value

<< Back to user notes page

To Top