1 <?php 2 /** 3 * 2.2.5重写静态变量 4 * @authors haidong (admin@zhe700.net) 5 * @date 2015-03-23 14:34:35 6 * @version $Id$ 7 */ 8 9 class myObject{ 10 11 public static $myStaticVar = 0; 12 function myMethod(){ 13 self::$myStaticVar += 2; 14 echo self::$myStaticVar . "<br/>"; 15 } 16 } 17 class myExtendObject extends myObject{ 18 public static $myStaticVar = 0; 19 function myExtendMethod(){ 20 echo parent::$myStaticVar . "<br/>"; 21 echo self::$myStaticVar . "<br/>"; 22 } 23 } 24 $instance1 = new myObject(); 25 $instance1->myMethod(); 26 $instance2 = new myObject(); 27 $instance2->myMethod(); 28 $instance3 = new myExtendObject(); 29 $instance3->myExtendMethod();