It changes the semantics. If the variable is set to a falsey value and ?:
uses an implicit isset, the value of the expression will be the falsey
value.

   $config['width'] = ''
   $width = $config['width'] ?: 300
   # $width == ''

If !empty were used instead of isset, you could preserve semantics ($a ?:
dflt = !empty($a) ? $a : dflt).


Since this has been discussed before, here's a previous solution with zero of those problems:

// A new operator.
$width = $config['width'] ?? 300;

// Actual behavior of the operator in pseudo code:
$width = isset($config['width']) ? $config['width'] : 300;

Why wasn't it implemented? No reason, it just wasn't. But people keep asking about it, so it's only a matter of time.

Stan

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to