php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36022 Function call by reference: undocumented BC-break
Submitted: 2006-01-15 16:08 UTC Modified: 2006-01-15 16:12 UTC
From: mail at garv dot in Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.1.2 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mail at garv dot in
New email:
PHP Version: OS:

 

 [2006-01-15 16:08 UTC] mail at garv dot in
Description:
------------
When calling a function that expects an argument as a referenced variable, you cannot pass an assignment operation to the function. If doing so, the function will not change the assignment operation by reference.

This has worked before PHP 5.1.2.

Reproduce code:
---------------
<?php
function myFunc(&$var) {
    $var = 'set in function';
}

$var = 'set before function';
myFunc($var = 'set in function call');

var_dump($var);
?>


Expected result:
----------------
PHP lower than 5.1.2 reported "set in function", which is the expected behaviour.

Actual result:
--------------
PHP 5.1.2 actually reports "set in function call", which is not the expected behaviour and thus a BC break.

I guess this change is a side-effect of recent "return by reference" problems that were addressed in PHP 4.4 already. 

I personally do not use code above, but other PHP applications like phpMyAdmin do (did). So at least having this documented in the PHP5 ChangeLog as a BC break would've been nice - just in case this change is "by intention".

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-15 16:12 UTC] derick@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Duplicate of: #35995.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 20:00:02 2026 UTC