Coalescing PHP – Elegant PHP coding

 

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

Comments

Popular posts from this blog

Best PHP comment DockBlock !

How to fix pgDump dbeaver ?