我試圖加載一個命名空間和一個名字我只知道一個變量的值的類。動態加載命名空間和類
我想這一點:
<php
/**
* Namespaces and class have the same name.
*/
require_once($arg1 . '.class.php');
use \$arg1\$arg1;
/**
* also I have try
* use \{$arg1}\{$arg1};
*/
$object = new $arg1();
var_dump($object);
?>
它給我回:
PHP Parse error: syntax error, unexpected '$arg1' (T_VARIABLE), expecting identifier (T_STRING) in /home/vagrant/execute.php on line 5
有任何的方式來加載這個,還是我嘗試用工廠模式,使之?
我的PHP版本PHP 5.6.14-0 + deb8u1,而且我還有chante require_once $ arg1。 「.class.php」;但是有同樣的錯誤。 –