php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41781 PHP loses the reference to the default parameter
Submitted: 2007-06-22 15:14 UTC Modified: 2007-06-25 17:48 UTC
From: skettler@php.net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.3 OS: Linux 2.6.20.2 / Debian Sarge
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: skettler@php.net
New email:
PHP Version: OS:

 

 [2007-06-22 15:14 UTC] skettler@php.net
Description:
------------
When using a pass by reference parameter with a default value, the scripting engine does not always remember that reference.

The script shows that

    ++$i;
    func($i);

and

    func(++$i);

are not equivalent at all times. When not using the default value and submitting an actual variable, both expressions are handled the same way.

Reproduce code:
---------------
See http://helplets.com/PHP/referencebug.txt

Expected result:
----------------
0123456
--------
0123456
--------
0123456


Actual result:
--------------
0123456
--------
01234545
--------
0123456


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-25 17:48 UTC] tony2001@php.net
0123456
--------
0
Strict Standards: Only variables should be passed by reference in /tmp/3.php on line 26
1
Strict Standards: Only variables should be passed by reference in /tmp/3.php on line 26
2
Strict Standards: Only variables should be passed by reference in /tmp/3.php on line 20
3
Strict Standards: Only variables should be passed by reference in /tmp/3.php on line 26
4
Strict Standards: Only variables should be passed by reference in /tmp/3.php on line 26
5
Strict Standards: Only variables should be passed by reference in /tmp/3.php on line 26
4
Strict Standards: Only variables should be passed by reference in /tmp/3.php on line 26
5
--------
0123456

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC