标签: php class
如何设置php类的var名称动态?
示例:
$var_name = "new_var"; $class->{$var_name} = "new value";
没关系?
答案 0 :(得分:1)
$class->$var_name = "new value";
http://codepad.org/KKAwSQdA
答案 1 :(得分:1)
是的,没关系。你至少试过吗?
http://php.net/manual/en/language.variables.variable.php