dereference_008.phpt 388 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. Testing array dereference with dynamic method name and references
  3. --FILE--
  4. <?php
  5. error_reporting(E_ALL);
  6. class foo {
  7. public $x = array(1);
  8. public function &b() {
  9. return $this->x;
  10. }
  11. }
  12. $foo = new foo;
  13. $a = 'b';
  14. var_dump($foo->$a()[0]);
  15. $h = &$foo->$a();
  16. $h[] = 2;
  17. var_dump($foo->$a());
  18. ?>
  19. --EXPECT--
  20. int(1)
  21. array(2) {
  22. [0]=>
  23. int(1)
  24. [1]=>
  25. int(2)
  26. }