在php.net中是这样写的:
Variable functions won't work with language constructs such as echo, print, unset(), isset(), empty(), include, require and the like. Utilize wrapper functions to make use of any of these constructs as variable functions.
这是什么意思?
谁能举个例子,因为我试过在 echo 中使用变量函数并且效果很好:
function city()
{
return "new york";
}
$var = "city";
echo "city: " . $var();
最佳答案
这意味着你不能做这样的事情:
$var = "echo";
$var "Hello World!";
关于php - PHP 中的变量函数是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21409213/