bug44899_2.phpt 718 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. Bug #44899 (__isset usage changes behavior of empty()) - 2
  3. --FILE--
  4. <?php
  5. class myclass
  6. {
  7. private $_data = array();
  8. function __construct($data)
  9. {
  10. $this->_data = $data;
  11. }
  12. function __isset($field_name)
  13. {
  14. return isset($this->_data[$field_name]);
  15. }
  16. function __get($var) {
  17. var_dump(empty($this->_data[$var]));
  18. return $this->_data[$var];
  19. }
  20. }
  21. $arr = array('foo' => '');
  22. $myclass = new myclass($arr) ;
  23. echo (isset($myclass->foo)) ? 'isset' : 'not isset';
  24. echo "\n";
  25. echo (empty($myclass->foo)) ? 'empty' : 'not empty';
  26. echo "\n";
  27. echo ($myclass->foo) ? 'not empty' : 'empty';
  28. echo "\n";
  29. ?>
  30. --EXPECT--
  31. isset
  32. bool(true)
  33. empty
  34. bool(true)
  35. empty