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.
我正在尝试创建一个变量并在另一个变量的内容之后为其命名。例如
$newname = "x"; //dosomething to create the variable $x
它们被称为变量变量:
${$newname} = 'stuff';
如果您有更多,请考虑使用数组和其中的extract变量:
extract
$vars = array(...); // keys = variable name, value = variable value extract($vars, EXTR_SKIP);
检查这个:
$a = 'hello'; $$a = 'world'; echo "$a ${$a}"; echo "$a $world";
希望有用。