Last active
August 29, 2015 13:59
-
-
Save mrded/10982300 to your computer and use it in GitHub Desktop.
PHP: ArrayObject bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$obj = new ArrayObject(); | |
$obj['hello'] = NULL; | |
print 'ArrayObject<br >'; | |
var_dump(empty($obj['hello'])); // TRUE | |
var_dump(isset($obj['hello'])); // FALSE | |
var_dump(array_key_exists('hello', $obj)); // TRUE | |
class Test1 extends ArrayObject { | |
public function offsetExists($index) { | |
return parent::offsetExists($index); | |
} | |
public function offsetGet($index) { | |
return parent::offsetGet($index); | |
} | |
} | |
$obj = new Test1(); | |
$obj['hello'] = NULL; | |
print 'Test1<br >'; | |
var_dump(empty($obj['hello'])); // FALSE | |
var_dump(isset($obj['hello'])); // TRUE | |
var_dump(array_key_exists('hello', $obj)); // TRUE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment