Req #74028 [NEW]: new combined operators ?= and ??=
| From: | from_php at puggan dot se | Date: | Wed, 01 Feb 2017 15:14:11 +0000 |
| Subject: | Req #74028 [NEW]: new combined operators ?= and ??= | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-207103@lists.php.net to get a copy of this message | ||
From: from_php at puggan dot se
Operating system:
PHP version: Irrelevant
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:new combined operators ?= and ??=
Description:
------------
Could you make 2 new combined operators:
$a ?= 4 => $a = $a ?: 4
AND
$a ??= 4 => $a = $a ?? 4
Test script:
---------------
<?php
function ofstr($a = NULL, $b = NULL)
{
$a ?= 1;
$b ?= 100;
return "$a of $b";
}
print_r(
array(
ofstr(2, 5),
ofstr(60),
ofstr(FALSE, 5)
)
);
Expected result:
----------------
Array
(
[0] => 2 of 5
[1] => 60 of 100
[2] => 1 of 5
)
--
Edit bug report at https://bugs.php.net/bug.php?id=74028&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74028&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74028&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74028&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74028&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74028&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74028&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74028&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74028&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74028&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74028&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74028&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74028&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74028&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74028&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74028&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74028&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74028&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74028&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74028&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74028&r=mysqlcfg