note 123795 added to migration70.new-features

From: Date: Tue, 23 Apr 2019 20:08:44 +0000
Subject: note 123795 added to migration70.new-features
Groups: php.notes 
Request: Send a blank email to php-notes+get-210662@lists.php.net to get a copy of this message
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?" ?> :) ---- Server IP: 208.43.231.9 Probable Submitter: 82.199.157.34 (proxied: 181.129.187.219) ---- Manual Page -- http://php.net/manual/en/migration70.new-features.php Edit -- https://master.php.net/note/edit/123795 Del: integrated -- https://master.php.net/note/delete/123795/integrated Del: useless -- https://master.php.net/note/delete/123795/useless Del: bad code -- https://master.php.net/note/delete/123795/bad+code Del: spam -- https://master.php.net/note/delete/123795/spam Del: non-english -- https://master.php.net/note/delete/123795/non-english Del: in docs -- https://master.php.net/note/delete/123795/in+docs Del: other reasons-- https://master.php.net/note/delete/123795 Reject -- https://master.php.net/note/reject/123795 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#210662) next »