摘要:
1. PHP 变量的作用域参见 php 手册: Language Reference - Variables - Variable scope<?php$a = 1; /* global scope */ function test(){ echo $a; /* reference to local scope variable */ } test();?> 在 C 语言中,变量的作用域是从声明到文件结束,所以会误以为能输出 a 的值。但是,和 C 语言的全局变量不同,php的全局变量必须在函数体内进行声明。PHP 中声明全局变量的方式:使用 global 关键字: 表明本变量是全 阅读全文
posted @ 2012-09-04 20:17
handt
阅读(256)
评论(0)
推荐(0)

浙公网安备 33010602011771号