

php在类中使用静态方法的方式:
1、使用self,代码如下
<?php 
class a { 
 private static function test() { 
 echo 'test'; 
 } 
 public function test1() { 
 self::test(); 
 } 
} 
$ab = new a(); 
$ab->test1();//结果 test2、使用类名,代码如下
<?php 
class a { 
 private static function test() { 
 echo 'test'; 
 } 
 public function test1() { 
 a::test(); 
 } 
} 
$ab = new a(); 
$ab->test1();//结果 test3、使用static,代码如下
<?php 
class a { 
 private static function test() { 
 echo 'test'; 
 } 
 public function test1() { 
 static::test(); 
 } 
} 
$ab = new a(); 
$ab->test1();//结果 test相关免费学习推荐:php编程(视频)
