0
$this->property = 'SomeClass';

$x = new $this->property();     // works
$x = $this->property::create(); // fails (parse error)

これはPHPのバグですか?

新しい変数に値を割り当てずに、プロパティを使用して静的メソッドを呼び出すことができますか?代わりにその変数を使用しますか?

4

2 に答える 2

2

使用するcall_user_func

$x = call_user_func(array($this->property, 'create'));
于 2012-10-22T01:37:26.960 に答える
1

数か月間バグとして入力されており、まだオープンステータスになっているので、はいを使用します。

https://bugs.php.net/bug.php?id=61397

同様に、

https://bugs.php.net/bug.php?id=54095

于 2012-10-22T02:15:55.267 に答える