php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46786 numeric variable & get_defined_vars()'s return come's something not expect.
Submitted: 2008-12-06 17:50 UTC Modified: 2008-12-08 10:33 UTC
From: caoxingk at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.7 OS: win_nt
Private report: No CVE-ID: None
 [2008-12-06 17:50 UTC] 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>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-08 10:33 UTC] jani@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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 04:01:32 2024 UTC