php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41312 pass by reference works without storage
Submitted: 2007-05-07 11:42 UTC Modified: 2007-05-07 12:09 UTC
From: vinhar at optusnet dot com dot au Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5CVS-2007-05-07 (CVS) OS: windows 5 sp4
Private report: No CVE-ID: None
 [2007-05-07 11:42 UTC] vinhar at optusnet dot com dot au
Description:
------------
A function defined to return by reference returns data when there is no storage to reference without a warning or notice.
Error reporting is E_ALL.
Version 5.0.33

Reproduce code:
---------------
<?
&bug()
{
    return 1 + 1;
}
$r = bug();
echo $r;
?>


Expected result:
----------------
A warning or notice as follows.

[NOTICE: Only variable references should be returned by reference]



Actual result:
--------------
The above function outputs 2.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-07 12:09 UTC] bjori@php.net
[bjori@lindsay ~]$ php -derror_reporting=8191 -a
Interactive mode enabled

<?php
function &bug()   
{
        return 1 + 1; 
}
$r = bug();
PHP Notice:  Only variable references should be returned by reference in /usr/home/bjori/- on line 6

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 01:01:35 2025 UTC