<?php class Car { private static $speed = 10; public function getSpeed() { return self::$speed; } //在這里定義一個靜態方法,實現速度累加10 static function speedup() { //訪問靜態屬性 //類名稱::$屬性名 //self::$屬性名 //parent::$屬性名 //訪問類內屬性 $this->屬性名
<?php class Car { private static $speed = 10; public function getSpeed() { return self::$speed; } //在這里定義一個靜態方法,實現速度累加10 static function speedup() { //訪問靜態屬性 //類名稱::$屬性名 //self::$屬性名 //parent::$屬性名 //訪問類內屬性 $this->屬性名
2014-07-12
舉報