php 静态变量知识点

2019-06-05  本文已影响0人  anthonydan

test1.php

<?php
$a = 5;
function test() {
    static $a = 0;
    return ++$a;
}

echo test();
echo test();
echo test();
exit;

结果:123

test2.php

<?php
$a = 5;
function test() {
    $a = 0;
    return ++$a;
}

echo test();
echo test();
echo test();
exit;

结果:111

上一篇 下一篇

猜你喜欢

热点阅读