首页 | 源码下载 | 网站模板 | 网页特效 | 广告代码 | 网页素材 | 字体下载 | 书库 | 站长工具
会员投稿 投稿指南 RSS订阅
当前位置:主页>网络编程>PHP教程>资讯:php funciton 中的static

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的变量初始化只执行一次

上一篇:PHP无限分类的原理 下一篇:PHP通过两种方式伪造来路

评论总数:0 [ 查看全部 ] 网友评论


关于我们隐私版权广告服务友情链接联系我们网站地图