PHP学習ノート二十二【静的方法二】

2046 ワード

<?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;

?>