• 2.2.5重写静态变量


     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();

  • 相关阅读:
    十年经验手把手教你选购翡翠
    眼睛视力
    玻璃
    前端小技巧
    儿童牙齿矫正
    MySQL的JDBC驱动源码解析
    书海杂谈
    电子设备
    股市国家队
    影视
  • 原文地址:https://www.cnblogs.com/haidong/p/4359781.html
Copyright © 2020-2023  润新知