php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36654 ignoring passing expression by reference
Submitted: 2006-03-08 13:11 UTC Modified: 2006-03-08 13:28 UTC
From: tomek at realtsp dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.1.2 OS: FreeBSD
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: tomek at realtsp dot com
New email:
PHP Version: OS:

 

 [2006-03-08 13:11 UTC] tomek at realtsp dot com
Description:
------------
If we pass an expression by reference, it doesn't recognize the variable from the expression, but doesn't complain about that fact either.

As written in http://www.php.net/manual/en/language.references.pass.php, such statement is invalid. Strangely enough it worked up to 5.0.4 (and 5.0.5 perhaps) and stopped working after upgrade to 5.1.2.

Moreover, since both remaining examples from the documentation produce a fatal error, it would seem natural if that one would as well.

Reproduce code:
---------------
<?php

function inc(&$a)
{
  $a++;
}

// $b = 3;
// inc($b);
inc($b = 3);
echo $b ."\n";

?>

Expected result:
----------------
Either 4 or a fatal error, rather than silently doing nothing.

Actual result:
--------------
3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-08 13:28 UTC] tony2001@php.net
Turn on E_STRICT error messages.
Strict Standards: Only variables should be passed by reference in
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Aug 02 15:00:03 2025 UTC