PHP class knowledge ---- static properties and methods

<? PHP
 class mycoach 
{ 
    public $ name = " Chen Peichang " ; 
    CONST hisage = 22 is ;
     public  static $ earnfor = 2789 ;
     Private $ = Favorite " like cauldron D " ;
     public function the __construct () 
    { 
        echo " {$ this-> name} So far, the value of the equipment for the shop to sell " . .mycoach :: $ earnfor " yuan " .PHP_EOL; 
    } 
    public  static function DECLARE () 
    { 
        echo" Turn off the lights, right, Ding cauldron, today too tired to play the " .PHP_EOL; 
    } 
} 
$ cpc = new new mycoach (); 
mycoach :: DECLARE ();
 ?>

Static properties and methods belong to the class, the specific meaning, if appropriate share some attributes, then there is no need for every instance of an object, that would be a waste of space, in other words no matter how many objects on a static properties part

Static property access methods ---- attribute class name ::

Guess you like

Origin www.cnblogs.com/saintdingspage/p/10988379.html