note 123795 deleted from migration70.new-features by peehaa

From: Date: Sun, 28 Apr 2019 09:43:18 +0000
Subject: note 123795 deleted from migration70.new-features by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210699@lists.php.net to get a copy of this message
Note Submitter: Alekz ---- The "??" operator is for checking variable existance too: <?php $a = null; echo $a ?? "Something else"; // Echoes: "Something else" echo $b ?? "Other Value"; // Note: $b does not exist, so "??" gives "Other Value" as output // Echoes "Other Value" ?> The same for arrays, even if array does not exist, "??" operator will not show any error, and works as expected: <?php $a = []; $a["sausage"] = null; echo $a["sausage"] ?? 'Breath'; // Echoes: "Breath" echo $b["sausage"] ?? 'Who made this?'; // This array does not exist // Echoes "Who made this?" ?> :)

« previous php.notes (#210699) next »