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.
PHP5.3 是否有任何已知的错误问题使范围内的非静态变量表现为静态?我不知道为什么在我的 if{}范围内
{ echo $_not_static; $_not_static = 5; }
第一次它应该触发 E_NOTICE 但第二次它打印 5。我为此苦苦挣扎了 3 个多小时,但没有从我这边得到任何故障提示。
变量是函数范围的,无论它们位于哪个块中,并且在任何 PHP 版本中都是如此。如果您在 if 块中声明一个变量,然后在其中输入,它将在 if 完成后在整个函数范围内保持声明。