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_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