在搜索其他内容时,我发现了这段代码
$x = "foo";
function foo(){ echo "wtf"; }
$x(); # "wtf"
当我搜索谷歌这个时,我得到的只有C结果而不是PHP,而我知道在PHP引擎盖下是C,我真的想要一些解释.
这叫什么?
以及它如何被PHP zend解释?它是某种可赎回的吗?
它仍然可以在PHP 7中使用吗?
解决方法:
>它是可调用的(可变函数:http://php.net/manual/en/functions.variable-functions.php)
> Zend只是将它视为可调用并调用该函数.
>这是一个古老而稳定的语言功能,仍然可以在PHP7中使用(并且它将尽可能长)
Callable | Normalization | Type
--------------------------------+---------------------------------+--------------
function (...) use (...) {...} | function (...) use (...) {...} | 'closure'
$object | $object | 'invocable'
"function" | "function" | 'function'
"class::method" | ["class", "method"] | 'static'
["class", "parent::method"] | ["parent of class", "method"] | 'static'
["class", "self::method"] | ["class", "method"] | 'static'
["class", "method"] | ["class", "method"] | 'static'
[$object, "parent::method"] | [$object, "parent::method"] | 'object'
[$object, "self::method"] | [$object, "method"] | 'object'
[$object, "method"] | [$object, "method"] | 'object'
标签:php,function,string
来源: https://codeday.me/bug/20190727/1550123.html