bug21669.phpt 396 B

1234567891011121314151617181920212223
  1. --TEST--
  2. Bug #21669 ("$obj = new $this->var;" doesn't work)
  3. --FILE--
  4. <?php
  5. class Test {
  6. function say_hello() {
  7. echo "Hello world";
  8. }
  9. }
  10. class Factory {
  11. public $name = "Test";
  12. function create() {
  13. $obj = new $this->name; /* Parse error */
  14. return $obj;
  15. }
  16. }
  17. $factory = new Factory;
  18. $test = $factory->create();
  19. $test->say_hello();
  20. ?>
  21. --EXPECT--
  22. Hello world