Categories
BEST PHP CODE

coalescing PHP – Elegant PHP

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’;

source : http://php.net/manual/en/migration70.new-features.php

Leave a Reply