小编Ald*_*ein的帖子

if语句中的php static

我的配置文件中有这样的结构:

<?php
if (true) {
    $nonstatic = 1;
    static $config = 1;
}
else {
    $nonstatic = 2;
    static $config = 2;
}

echo $nonstatic;
echo $config;
?>
Run Code Online (Sandbox Code Playgroud)

那么为什么$ config包含2如果该部分语句为false且$ nonstatic包含1?这是一个错误吗?

php static if-statement variable-declaration

9
推荐指数
1
解决办法
262
查看次数

标签 统计

if-statement ×1

php ×1

static ×1

variable-declaration ×1