note 120961 added to language.operators.logical
| From: | dumitru at floringabriel dot com | Date: | Mon, 10 Apr 2017 10:54:42 +0000 |
| Subject: | note 120961 added to language.operators.logical | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209020@lists.php.net to get a copy of this message | ||
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
----
Server IP: 72.52.91.14
Probable Submitter: 5.12.255.5
----
Manual Page -- http://php.net/manual/en/language.operators.logical.php
Edit -- https://master.php.net/note/edit/120961
Del: integrated -- https://master.php.net/note/delete/120961/integrated
Del: useless -- https://master.php.net/note/delete/120961/useless
Del: bad code -- https://master.php.net/note/delete/120961/bad+code
Del: spam -- https://master.php.net/note/delete/120961/spam
Del: non-english -- https://master.php.net/note/delete/120961/non-english
Del: in docs -- https://master.php.net/note/delete/120961/in+docs
Del: other reasons-- https://master.php.net/note/delete/120961
Reject -- https://master.php.net/note/reject/120961
Search -- https://master.php.net/manage/user-notes.php