Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@arraypad
Created March 31, 2013 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arraypad/5280321 to your computer and use it in GitHub Desktop.
Save arraypad/5280321 to your computer and use it in GitHub Desktop.
--TEST--
Array key within interned string gets wrong hash value
--FILE--
<?php
class Foo
{
protected $unsetme = 1;
protected $keepme = 2;
public function test()
{
$a = get_object_vars($this);
foreach ($a as $k => $v) {
if ($k == 'unsetme') {
echo "Unsetting: $k\n";
unset($a[$k]);
} else if ($k == 'keepme') {
echo "Changing: $k\n";
$a[$k] = 42;
$a['keepme'] = 43;
}
}
var_dump($a, array_keys($a));
}
}
$f = new Foo;
$f->test();
?>
--EXPECT--
Unsetting: unsetme
Changing: keepme
array(1) {
["keepme"]=>
int(43)
}
array(1) {
[0]=>
string(6) "keepme"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment