note 120359 added to function.isset

From: Date: Wed, 21 Dec 2016 01:04:01 +0000
Subject: note 120359 added to function.isset
Groups: php.notes 
Request: Send a blank email to php-notes+get-208678@lists.php.net to get a copy of this message
The new (as of PHP7) 'null coalesce operator' allows shorthand isset. You can use it like so: <?php // Fetches the value of $_GET['user'] and returns 'nobody' // if it does not exist. $username = $_GET['user'] ?? 'nobody'; // This is equivalent to: $username = isset($_GET['user']) ? $_GET['user'] : 'nobody'; // Coalescing can be chained: this will return the first // defined value out of $_GET['user'], $_POST['user'], and // 'nobody'. $username = $_GET['user'] ?? $_POST['user'] ?? 'nobody'; ?> Quoted from http://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op ---- Server IP: 72.52.91.14 Probable Submitter: 122.56.100.154 ---- Manual Page -- http://php.net/manual/en/function.isset.php Edit -- https://master.php.net/note/edit/120359 Del: integrated -- https://master.php.net/note/delete/120359/integrated Del: useless -- https://master.php.net/note/delete/120359/useless Del: bad code -- https://master.php.net/note/delete/120359/bad+code Del: spam -- https://master.php.net/note/delete/120359/spam Del: non-english -- https://master.php.net/note/delete/120359/non-english Del: in docs -- https://master.php.net/note/delete/120359/in+docs Del: other reasons-- https://master.php.net/note/delete/120359 Reject -- https://master.php.net/note/reject/120359 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#208678) next »