开发者

What does the global keyword do if it is not used in the scope of a function?

What does the global keyword do if it is not used in the scope of a function (file is not included from inside a function)

<?php 
error_reporting(E_ALL);
$a=1;
global $a;
echo $a;
?>
  1. Using global keyword outside a function is not an error. [Tick]

  2. It can be used if the file is included from inside a function. [Tick开发者_JAVA技巧]

  3. But what does the global keyword do when it is used in a "global file" (file that is not included from inside a function) ?


From http://php.net/manual/en/language.variables.scope.php :

Using global keyword outside a function is not an error. It can be used if the file is included from inside a function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜