php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69300 $GLOBALS always assigned as reference variable.
Submitted: 2015-03-25 19:45 UTC Modified: 2015-03-25 20:15 UTC
From: sandeep dot singh dot bisht at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: Irrelevant OS: Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sandeep dot singh dot bisht at gmail dot com
New email:
PHP Version: OS:

 

 [2015-03-25 19:45 UTC] sandeep dot singh dot bisht at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/reserved.variables.globals
---


Test script:
---------------
<?php
#---------------------------------------------------------
#---First Normal case(GLOBAL variable assign to local variable)
#---------------------------------------------------------
$GLOBALS['abc']='123';
$test1=$GLOBALS;
$test1['abc']='1234';
echo $GLOBALS['abc']."\n"; #----------Output is 1234 Expecting 123
#--------------------------------------------------------------------
#---Function test case(Global variable assign into variable inside function)
#----------------------------------------------------------------------
test();
echo $GLOBALS['abc']."\n";#-----------Output is 0000 Expecting 123
function test()
{
        $test=$GLOBALS;
        $test['abc']='0000';
}
?>



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-25 20:15 UTC] cmb@php.net
-Status: Open +Status: Not a bug
 [2015-03-25 20:15 UTC] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The manual states:

| An associative array containing *references* to all variables
| which are currently defined in the global scope of the script.

(emphasis mine)
 [2015-03-25 20:15 UTC] cmb@php.net
-Package: Testing related +Package: Scripting Engine problem
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 16:01:37 2025 UTC