php - php 中的 static 行为异常,无法接受函数

标签 php php-5.3

此代码抛出解析错误,我不明白为什么。

function t(){
 return 'g';
}
function l(){
    static $b = t();
    return $b;
}
l();

问题是,为什么?

最佳答案

引用手册:

Note:

Trying to assign values to these [static] variables which are the result of expressions will cause a parse error.

(我的重点)

比较http://www.php.net/manual/en/language.variables.scope.php示例#7

关于php - php 中的 static 行为异常,无法接受函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8782094/

相关文章:

php - docker nginx php-fpm file_get_contents无法正常工作

php - 如何在 Doxygen 中禁用斜杠命令语法

PHP MySQL错误设置

php - 在 PHP7/HHVM 的新 MongoDB 库中使用正则表达式

php - angularjs - 将对象数组(JSON 数据)发布到 PHP 页面

php - 是否可以将 phar 放入 phar 中?

php-5.3 - 成功执行worker后获取数据 gearman

PHP 类型提示错误?

php - 在 PHP 单页应用程序中调用 AJAX 链接到内部页面时遇到问题

php - 使用动态数组创建数组键名