php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62664 Passing inline-set variables by reference fails
Submitted: 2012-07-26 08:31 UTC Modified: 2012-07-26 23:47 UTC
From: katelyn dot schiesser at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.15 OS: Centos 6.2
Private report: No CVE-ID: None
 [2012-07-26 08:31 UTC] katelyn dot schiesser at gmail dot com
Description:
------------
I apologize in advance if this has been reported elsewhere, I searched without 
finding anything.

I have tested this on boxes running versions of PHP 5.3.13, and 5.3.3.

[slowbro@node05 ~]$ php -v
PHP 5.3.3 (cli) (built: Jul  3 2012 16:53:21)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

The issue is that I can't pass inline-set variables by reference.

For example, this works:

test($var='something');


...but this doesn't:

test(&$var='something');


Perhaps this is the way the engine works or something- but I would think it 
would be easy enough to (and make sense to) allow this.

Test script:
---------------
function test(&$var){
  $var = 'something else';
}

test(&$newvar='something');
echo $newvar;

Expected result:
----------------
something else

Actual result:
--------------
PHP Parse error:  syntax error, unexpected '=', expecting ')' in php shell code on 
line 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-26 21:26 UTC] cataphract@php.net
-Status: Open +Status: Not a bug
 [2012-07-26 21:26 UTC] cataphract@php.net
That you for your report, but it's simply not supported. Given that call-time pass-by-ref was removed in PHP 5.4, there's no point in even considering supporting such a case.
 [2012-07-26 23:47 UTC] katelyn dot schiesser at gmail dot com
So you're saying they removed things like: 

test(&$var)

For functions that aren't defined to accept variables passed by reference?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Sep 10 22:00:01 2025 UTC