#46786 [Opn->Bgs]: numeric variable & get_defined_vars()'s return come's something not expect.
| From: | jani@php.net | Date: | Mon, 08 Dec 2008 10:33:32 +0000 |
| Subject: | #46786 [Opn->Bgs]: numeric variable & get_defined_vars()'s return come's something not expect. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-131732@lists.php.net to get a copy of this message | ||
ID: 46786
Updated by: jani@php.net
Reported By: caoxingk at gmail dot com
-Status: Open
+Status: Bogus
-Bug Type: Unknown/Other Function
+Bug Type: Scripting Engine problem
Operating System: win_nt
PHP Version: 5.2.7
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2008-12-06 17:50:47] caoxingk at gmail dot com
Description:
------------
<pre>
file NumericVarName.php
<?php
$TestVar = 8888;
$$TestVar = 'See the KEY\'s type...';
$SeeThis = get_defined_vars();
function MyEcho($_Msg) {echo '<script>alert(\'' . $_Msg .
'\');</script>';}
isset($$TestVar) && MyEcho('Case A!');
isset($SeeThis[8888]) && MyEcho('Case B!');
isset($SeeThis['8888']) && MyEcho('Case C!');
foreach ($SeeThis as $_Ui => $_Uk) {
($_Ui === 8888) && $_Temp = 'Case B too!';
($_Ui === '8888') && $_Temp = 'Case C too!';
isset($_Temp) && MyEcho($_Temp);
}
?>
------------------------------------------------------------------------------
My English is poor.Just explain my question shortly:
The output contains "Case A!" & "Case C too!",
but why not contain "Case C!" before "Case C too!" ?
------------------------------------------------------------------------------
Hope you can analyse what I've talk about,
maybe something not expect comes such as:
- syntax-parser do not check "$$var" when "$var" is numeric.
- do "foreach array" with get_defined_vars()'s return has a
shortcoming.
- ...
Wish PHP better & better...
</pre>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46786&edit=1