note 112370 deleted from language.operators.comparison by crell

From: Date: Wed, 30 Mar 2022 21:45:30 +0000
Subject: note 112370 deleted from language.operators.comparison by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217787@lists.php.net to get a copy of this message
Note Submitter: damien dot launay dot mail at gmail dot com ---- I found a nice way to use of new "?:" operator: $a = array(); $a['foo'] = 'oof'; $b = @ ($a['foo'] ?: 'No foo'); $c = @ ($a['bar'] ?: 'No bar'); var_dump($b, $c); Output: string(3) "oof" string(6) "No bar" No error is thrown and $c is set with correct value. Benefit: no need to use isset.

« previous php.notes (#217787) next »