php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33822 Error : Only variables can be passed by reference
Submitted: 2005-07-22 15:00 UTC Modified: 2005-07-22 16:32 UTC
From: stochnagara at hotmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2005-07-22 (dev) OS: Windows XP
Private report: No CVE-ID: None
 [2005-07-22 15:00 UTC] stochnagara at hotmail dot com
Description:
------------
A strange bug with references is present in today's snaphshot (10:30) of PHP 5.1.

I call it bug because many old PHP scripts don't work anymore.

The problem is that passing an argument to a function expecting a reference when this argument retreived by another function call, causes a Fatal Error.

With PHP 5.0.4 it works fine.

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

function a (&$str) {
	echo 'hi';
}

function b ($str) {
	return $str . 'hi';
}

echo a (b('1'));


Expected result:
----------------
hi

Actual result:
--------------
Fatal error: Only variables can be passed by reference in C:\Program Files\Apache Group\...\test.php on line 11

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-22 16:32 UTC] tony2001@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.

See #33643.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 12:00:01 2026 UTC