1 <?php
 2 
 3 class Char{
 4     public static $number = 0;
 5     public static $name;
 6     
 7     function __construct($what){
 8         self::$name = $what;
 9     }
10     public static function  Join(){
11         self::$number++;
12         echo self::$number," Is :",self::$name,"<br />";
13     }
14     
15 }
16 
17 $test = new Char('a');
18 Char::Join();
19 #注意, 在静态方法中不能访问非静态变量

#Char::Join();
#$test->Join();
#$test::Join();
可以这样调用


相关文章:

  • 2021-12-30
  • 2021-05-29
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
相关资源
相似解决方案