php函数引用

//在自定义函数中,前面加一个&符号,是对返回静态变量的引用
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

 

posted @ 2015-09-21 16:46  Sentiger  阅读(100)  评论(0编辑  收藏  举报