php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34698 bug with superglobal variables by name
Submitted: 2005-10-01 11:33 UTC Modified: 2005-10-01 13:04 UTC
From: andrius dot steponavicius at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.4.0 OS: win32
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrius dot steponavicius at gmail dot com
New email:
PHP Version: OS:

 

 [2005-10-01 11:33 UTC] andrius dot steponavicius at gmail dot com
Description:
------------
There is a bug while accessing superglobal variables by they names inside functions or methods...

Reproduce code:
---------------
function test()
{
    var_dump($_REQUEST);
    var_dump(${'_REQUEST'});
    $temp = '_REQUEST';
    var_dump(${$temp});
}

test();

Expected result:
----------------
array(...){...}
array(...){...}
array(...){...}

Actual result:
--------------
array(...){...}
array(...){...}
Notice: Undefined variable:  _REQUEST in ...
null

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-01 11:40 UTC] johannes@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

. 
 [2005-10-01 12:07 UTC] andrius dot steponavicius at gmail dot com
so.......

if this is NOT a BUG, then what is it ?..

what's wrong with my example code and HOW must I rewrote that stuff to make it work ? WHY I can access superglobal by writing direct name, by I can't using variable ?
 [2005-10-01 12:56 UTC] tony2001@php.net
Variable variables: Superglobals cannot be used as variable variables inside functions or class methods.
(c) http://www.php.net/manual/en/language.variables.predefined.php#language.variables.superglobals
 [2005-10-01 13:04 UTC] derick@php.net
That's how the super globals work...., see: http://no.php.net/variables.predefined
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 21:01:30 2024 UTC