php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53356 Allow use function return value in write context
Submitted: 2010-11-19 15:50 UTC Modified: 2015-04-06 09:30 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: lifinsky at yandex dot ru Assigned:
Status: Re-Opened Package: Scripting Engine problem
PHP Version: 5.3.3 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
47 - 29 = ?
Subscribe to this entry?

 
 [2010-11-19 15:50 UTC] lifinsky at yandex dot ru
Description:
------------
Allow use function return value in write context if this function return value by reference (Such as c or c++)

Test script:
---------------
function &test() {
	static $a = 0;
	return $a;
}

print(++test());
print(++test());
print(++test());


Expected result:
----------------
123

Actual result:
--------------
Fatal error

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-27 14:24 UTC] tyrael@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: tyrael
 [2015-03-27 14:24 UTC] tyrael@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

this will be supported in php7 as you can see here: http://3v4l.org/lCOIR
 [2015-03-27 14:30 UTC] nikic@php.net
-Status: Closed +Status: Re-Opened
 [2015-03-27 14:30 UTC] nikic@php.net
That change was not intentional and we may want to revert it. Especially given how it currently allows you to write this even if the function does not return by reference.
 [2015-04-06 09:30 UTC] tyrael@php.net
-Assigned To: tyrael +Assigned To:
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Sep 19 17:01:25 2020 UTC