Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我如何设置 php 类 var 名称动态?
例子:
$var_name = "new_var"; $class->{$var_name} = "new value";
没关系?
$class->$var_name = "new value";
http://codepad.org/KKAwSQdA
好的,可以。你至少试过了吗?
http://php.net/manual/en/language.variables.variable.php