Blogger Information
Blog 31
fans 2
comment 0
visits 27672
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
变量作用域
霏梦
Original
750 people have browsed it

- 作者:霏梦

  • 代码区
  1. <?php
  2. $name='wangwang';
  3. // 全局变量,不受作用域限制,
  4. function getName(){
  5. // php,函数会创建一个独立的作用域,不能直接访问外部的变量,
  6. // 要用到声明
  7. // 全局变量可以在整个页面操作有效,但是用之前要先声明一下
  8. // global $name;//全局变量 引用全局变量
  9. // return $name;
  10. // 超全局变量可以在整个网站内使用
  11. return $GLOBALS['name'];
  12. }
  13. echo getName();
  14. echo '<br>';
  15. echo $_SERVER['SERVER_ADDR'];
  16. echo $_SERVER['SERVER_NAME'];
  17. echo $_SERVER['REQUEST_TIME'];
  • 输出结果
    变更
Correcting teacher:天蓬老师天蓬老师

Correction status:unqualified

Teacher's comments:你觉得这样写合适吗?如果不想写就不要写了
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post