php中使用static方法
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();
可以这样调用