我的问题与这篇文章非常相似:[链接] Creating PHP class instance with a string我想从String实例化一个对象但是我的字符串来自一个对象属性,我有这个:
$type = strval($act->elementtype); $ty="Client";
$societe = new $type;
如果我更改$societe = new $ty
,即使$societe = new $type
等于$type
(我的班级名称),Client
也会有效。我收到了:
致命错误:在......中找不到“客户”类
答案 0 :(得分:0)
答案 1 :(得分:0)
嗯..如果有人在某个时候需要答案,他们认为我的BD elementtype
中的变量类型是type CHAR
所以我尝试在postgresql中更改它并将其设置为{{1}它有效!!希望它有所帮助! ^^