mirror of
https://github.com/php/php-src.git
synced 2024-12-18 06:21:41 +08:00
a50198d0fe
RFC: https://wiki.php.net/rfc/null_coalesce_equal_operator $a ??= $b is $a ?? ($a = $b), with the difference that $a is only evaluated once, to the degree that this is possible. In particular in $a[foo()] ?? $b function foo() is only ever called once. However, the variable access themselves will be reevaluated.
12 lines
211 B
PHP
12 lines
211 B
PHP
--TEST--
|
|
Coalesce assign (??=): Non-writable variable
|
|
--FILE--
|
|
<?php
|
|
|
|
function foo() { return 123; }
|
|
foo() ??= 456;
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Fatal error: Can't use function return value in write context in %s on line %d
|