码迷,mamicode.com
首页 > Web开发 > 详细

php函数引用

时间:2015-09-21 17:46:51      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

//在自定义函数中,前面加一个&符号,是对返回静态变量的引用
function &test(){
    static $a;
    $a += 1;
    echo $a;
    return $a;
}

//看展示
$t = test();    //$t结果为:1
$t = 5;
$t = test();    //$t结果为:2

$t = &test();   //$t结果为:3
$t = 5;
$t = test();    //$t结果为:6

 

php函数引用

标签:

原文地址:http://www.cnblogs.com/shiwenhu/p/4826608.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!