php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26047 Access to supervariables via $$variable does not function as documented.
Submitted: 2003-10-30 23:38 UTC Modified: 2003-10-31 07:50 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dw-bugs dot php dot net at botanicus dot net Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 4.3.3 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2003-10-30 23:38 UTC] dw-bugs dot php dot net at botanicus dot net
Description:
------------
From the implementation I suppose this is pretty obvious, but the following does not work:

   $data_source = '_POST';
   $data =& $$data_source;

'$data' does not point at $_POST as expected. I'd consider this a problem - your implementation is showing through. Either re-label $_POST, etc. as not actually being superglobals, or fix the underlying implementation (which does not at present match up with your documentation).

"""This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script."""

This statement is not true, since the variable is only 'automatic global' when referred to by name directly (and thus gets caught by your special case code). It does not actually exist in every scope.

I beg you not to mark this as a documentation problem and change the docs to mention this. Fix it! It's a horrible inconsistancy. This, along with a million other sour points, is the reason why I absolutely detest my day job at the minute. Come on guys! Do it for me!

Reproduce code:
---------------
$data_source = '_POST';
$data =& $$data_source;

echo gettype($data);

Expected result:
----------------
array

Actual result:
--------------
NULL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-31 04:44 UTC] andi@php.net
Hi,

This is by-design and it's the price you have to pay for these special superglobals. A price which is worth paying...
If this is not documented in the online docs then feel free to drop a line to phpdoc@lists.php.net with the wording you think should be added
 [2003-10-31 05:01 UTC] dw-bugs dot php dot net at botanicus dot net
Will this be fixed in Zend2?
 [2003-10-31 07:50 UTC] sniper@php.net
No. 
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jul 05 10:05:45 2022 UTC