Bug #52114 [Opn->Bgs]: Array key moves when using func_get_args()
| From: | dtajchreber@php.net | Date: | Thu, 17 Jun 2010 23:56:02 +0000 |
| Subject: | Bug #52114 [Opn->Bgs]: Array key moves when using func_get_args() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-151589@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52114&edit=1
ID: 52114
Updated by: dtajchreber@php.net
Reported by: iblue at gmx dot net
Summary: Array key moves when using func_get_args()
-Status: Open
+Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: Ubuntu Linux 10.04
PHP Version: 5.3.2
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
$arguments[0] is a string. $arguments[0]['key'] refers to an offset in
said
string. Non-integer offsets are converted to integers. Since the string
'key'
doesn't contain any valid numeric data, it turns into a 0.. so you're
checking if
the first character of the string is set... it is. :)
Read through this page for a more detailed explanation:
http://www.php.net/manual/en/language.types.string.php
Previous Comments:
------------------------------------------------------------------------
[2010-06-17 22:34:05] iblue at gmx dot net
Description:
------------
Arrays get scrambled when using func_get_args(). See code sample below.
Test script:
---------------
<?php
function foo(/* ... */) {
$arguments = func_get_args();
if(isset($arguments[0]['key'])) {
var_dump($arguments[0]);
var_dump($arguments[1]);
echo "You see that \$arguments[0] is a string, while \$arguments[1]
is an array.\n";
echo "So this code should never get executed.\n";
} else {
echo "Correct behaviour";
}
}
foo("some string", array("key" => "value"));
Expected result:
----------------
Script output:
Correct behaviour
Actual result:
--------------
Script output:
string(11) "some string"
array(1) {
["key"]=>
string(5) "value"
}
string(1) "s"
You see that $arguments[0] is a string, while $arguments[1] is an
array.
So this code should never get execute.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52114&edit=1