PHP:类成员变量 - 默认值

时间:2014-08-01 19:24:30

标签: php class

考虑以下因素:

<?php

class Tiger {
    static $stripes;
}

?>

Tiger::$stripes的价值是什么?

1 个答案:

答案 0 :(得分:0)

PHP类成员变量的默认值为null

Tiger::$stripes将为null

<?php

class Tiger {
    static $stripes;
}

var_dump( Tiger::$stripes );

?>

输出:

NULL

因此,$ stripe的这两个声明是等价的:

static $stripes = null;
  // (equivalent)
static $stripes;