看看下面的实例:
复制代码 代码如下:
function Test()
{
$w3sky = 0;
echo $w3sky;
$w3sky++;
}
?>
复制代码 代码如下:
function Test()
{
static $w3sky = 0;
echo $w3sky;
$w3sky++;
}
?>
复制代码 代码如下:
function Test()
{
static $count = 0;
$count++;
echo $count;
if ($count Test();
}
$count--;
}
?>
复制代码 代码如下:
function foo(){
static $int = 0;// correct
static $int = 1+2; // wrong (as it is an expression)
static $int = sqrt(121); // wrong (as it is an expression too)
$int++;
echo $int;
}
?>