Bug #48478 [Fbk->NoF]: Super-globals cannot be accessed with literal keys
| From: | php-bugs at lists dot php dot net | Date: | Mon, 18 Feb 2013 00:33:57 +0000 |
| Subject: | Bug #48478 [Fbk->NoF]: Super-globals cannot be accessed with literal keys | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-176743@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=48478&edit=1
ID: 48478
Updated by: php-bugs@lists.php.net
Reported by: arancaytar dot ilyaran at gmail dot com
Summary: Super-globals cannot be accessed with literal keys
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: Arrays related
Operating System: Ubuntu 9.04
PHP Version: 6CVS-2009-06-05 (snap)
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2010-06-08 15:36:54] tony2001@php.net
Please try using this snapshot:
http://snaps.php.net/php-trunk-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2009-06-06 10:57:49] arancaytar dot ilyaran at gmail dot com
Failed to add; this will also work:
print $_SERVER[(binary)'SCRIPT_NAME'];
That's pretty nasty to have to do consistently though. You could work around it by defining
constants for all keys:
define(SCRIPT_NAME, (binary)'SCRIPT_NAME');
print $_SERVER[SCRIPT_NAME];
But that's also ugly. It'd be more convenient if the keys were in Unicode by default.
------------------------------------------------------------------------
[2009-06-05 11:22:04] arancaytar dot ilyaran at gmail dot com
Description:
------------
In the current snapshot of PHP6, the values stored in the "internal" $_SERVER and $_ENV
super-globals cannot be accessed using literal string keys like $_SERVER['SCRIPT_NAME'].
This is because the array keys in these super-globals are of type "string", while literals
in the script implicitly are of type "unicode".
This problem does not occur in $_GET, $_POST and $_REQUEST, because the request parameter names are
implicitly in unicode too.
Reproduce code:
---------------
// This will fail and print a notice:
print $_ENV['SHELL'] . "\n";
// This works:
foreach($_ENV as $key => $value)
if ($key == 'SHELL')
print $_ENV[$key] . "\n";
// This will work:
foreach ($_ENV as $key => $value)
$_ENV["$key"] = $value;
print $_ENV['SHELL'] . "\n";
Expected result:
----------------
/bin/bash
/bin/bash
/bin/bash
Actual result:
--------------
Notice: Undefined index: SHELL in - on line 2
/bin/bash
/bin/bash
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=48478&edit=1