php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54657 Function parameters can no longer be named after superglobal variables
Submitted: 2011-05-04 14:04 UTC Modified: 2011-09-07 15:28 UTC
From: cataphract@php.net Assigned: cataphract
Status: Closed Package: Scripting Engine problem
PHP Version: trunk-SVN-2011-05-04 (SVN) OS: Any
Private report: No CVE-ID:
 [2011-05-04 14:04 UTC] cataphract@php.net
Description:
------------
There is a backwards incompatible change in trunk in that function can no longer have parameters with a name equal to the one of some superglobal.

This should either be fixed with the previous behavior (the parameter shadows the superglobal) or documented in UPGRADING.

Test script:
---------------
$ php -d error_reporting=-1
<?php
function a($GLOBALS) {
        $GLOBALS['h'] = 8;
}
$g = null;
a($g);
var_dump($h);

Expected result:
----------------
On 5.3:

Notice: Undefined variable: h in - on line 7
NULL


Actual result:
--------------
On trunk:

Fatal error: Cannot re-assign auto-global variable GLOBALS in - on line 2

Patches

Peimbert (last revision 2012-07-18 22:55 UTC) by eduardopeimbert at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-07 15:27 UTC] cataphract@php.net
Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=316364
Log: - Fixed doc bug #54657: Function parameters can no longer be named after
  superglobal variables.
 [2011-09-07 15:28 UTC] cataphract@php.net
-Status: Open +Status: Closed -Type: Bug +Type: Documentation Problem -Assigned To: +Assigned To: cataphract
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 18:01:53 2014 UTC