在PHP中没有任何if等的花括号是什么意思[重复]
问题描述:
This question already has an answer here:
What do curley braces without any if,while,for etc before them mean in PHP? E.g.
#Code
{
#Code
}
#Code
</div>
此问题已经存在 这里有一个答案: p>
-
参考 - 这个符号在PHP中意味着什么?
18 answers
\ n span>
li>
- 在花括号中包装一个程序块在php中做什么? \ r 2 answers span> li> ul> div>
curley在没有任何内容的情况下支持什么 if,while,for before在他们之前意味着在PHP? 例如 p>
#Code { #Code } #Code code> pre> div>
- 在花括号中包装一个程序块在php中做什么? \ r 2 answers span> li> ul> div>
答
They do/mean precisely nothing - they are only used (very rarely, and usually inappropriately) as a developer aide.
And, if anyone's wondering they don't affect variable scope either:
-> cat foo.php
<?php
$out = "yup";
{
echo "can access vars from outside? $out
";
$in = "yup";
}
echo "can access vars from inside? $in
";
-> php foo.php
can access vars from outside? yup
can access vars from inside? yup