标签:style blog color io sp div on log cti
<?PHP class Student{ public static $fee; public $name; //构造函数 function __construct($name) { $this->name=$name; } //入学,静态方法无法操作非静态变量,因为静态方法(变量)是属于类,而非静态的成员变量时属于对象的 static function enterSchool($ifee) { self::$fee+=$ifee; } } $student1=new Student("张三"); Student::enterSchool(100); //$student1->enterSchool(100); $student2=new Student("李四"); Student::enterSchool(100); echo "<br/>总学费".Student::$fee; ?>
标签:style blog color io sp div on log cti
原文地址:http://www.cnblogs.com/sumg/p/4052824.html