php中类的static变量使用
1 <?php
2 #访问静态变量
3 #类外部: 类名::$类变量名
4 #类内部: 娄名::$类变量名或self::$类变量名
5 class Char{
6 public static $number = 0;
7 public $name;
8
9 function __construct($what){
10 $this->name = $what;
11 }
12 function Join(){
13 self::$number++;
14 echo self::$number," Is :",$this->name,"<br />";
15 }
16
17 }
18
19 $test = range('a','z');
20 foreach($test as $values){
21 $what = new Char($values);
22 $what->Join();
23 }