php-src/tests/lang/bug21669.phpt

24 lines
396 B
Plaintext
Raw Permalink Normal View History

--TEST--
Bug #21669 ("$obj = new $this->var;" doesn't work)
--FILE--
<?php
class Test {
2020-02-04 05:52:20 +08:00
function say_hello() {
echo "Hello world";
}
}
class Factory {
2020-02-04 05:52:20 +08:00
public $name = "Test";
function create() {
$obj = new $this->name; /* Parse error */
return $obj;
}
}
$factory = new Factory;
$test = $factory->create();
$test->say_hello();
?>
--EXPECT--
Hello world