On 09/09/2014 18:08, rpar...@yamiko.org wrote:
I agree and think we should go with a different operator as others suggested. 
If not ?? than we could use ?=  like $foo ?= “default string”.

That reads like an assignment, rather than an expression - particularly given PHP's large number of evaluate-and-assign operators (+=, *=, etc).

Actually, that might be a useful addition in its own right.

For a full set, we could have the following:

// Evaluation as boolean:
$bar = (bool)$bar ? $bar : $baz;
$bar = $bar ? $bar : $baz;
$bar = $bar ?: $baz;
$bar ?:= $baz;

// Test for null  / isset:
$bar = isset($bar) ? $bar : $baz;
$bar = $bar ?? $baz;
$bar ??= $baz;

Not the most readable, perhaps, but then "shorthand" and "readable" are often in conflict with one another.

Regards,

--
Rowan Collins
[IMSoP]


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

Reply via email to