栏目导航
热点推荐
- 开发者必备,超实用的PHP代码片
- 提高PHP编程效率的53种方法
- PHP精华的代码收藏
- PHP.ini配置文件(中文)
- PHP如何防止注入及开发安全
- 提高PHP编程效率的53个要点
- 实际开发中可能用到的PHP的字符
- PHP无限分类的原理
- PHP验证码类代码( 最新修改,完全
- PHP判断端口是否打开的代码
- PHP网站转移实战经验之谈
- phpMyAdmin配置文件说明
阅览排行
php funciton 中的static
www.jz123.cn 2011-01-10 来源: 站长家园 责任编辑(袁袁) 我要投递新闻
<?php
function t(){
static $a= 0;
++ $a;
var_dump($a);
}
$i = 3;
while ($i--){
t();
}
结果 1 ,2,3
见手册 $a is initialized only in first call of function and every time the t() function is called it will print the value of $a and increment it.
static的变量初始化只执行一次
function t(){
static $a= 0;
++ $a;
var_dump($a);
}
$i = 3;
while ($i--){
t();
}
结果 1 ,2,3
见手册 $a is initialized only in first call of function and every time the t() function is called it will print the value of $a and increment it.
static的变量初始化只执行一次
0
上一篇:PHP无限分类的原理 下一篇:PHP通过两种方式伪造来路