10)global预定义变量

代码展示:

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn">
 3 <head>
 4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
 5     <title>网页标题</title>
 6     <meta name="keywords" content="关键字列表" />
 7     <meta name="description" content="网页描述" />
 8     <link rel="stylesheet" type="text/css" href="" />
 9     <style type="text/css"></style>
10     <script type="text/javascript"></script>
11 </head>
12 <body>
13 <?php
14 $v1 = 1;    //全局变量
15 $v2 = 2;
16 function f1(){
17     $v3 = 3;    //局部变量
18     $v4 = 4;
19     echo "<br />函数f1被调用!";
20 }
21 f1();
22 echo "<pre>GLOBALS数组内容为:<BR />";
23 var_dump($GLOBALS);
24 echo "</pre>";
25 ?>
26 </body>
27 </html>
原文地址:https://www.cnblogs.com/xiaoyoucai/p/7306960.html