天天看点

php静态类方法和函数的区别,详谈php静态方法及普通方法的区别

header('content-type:text/html;charset=utf-8');

class Human{

static public $head=1;

public function easyeat(){

echo '普通方法吃饭

';

}

static public function eat(){

echo '静态方法吃饭

';

}

public function intro(){

echo $this->name;

}

}

Error_reporting(E_ALL|E_STRICT);

//此时没有对象!方法可以执行

Human::eat();

Human::easyeat();

Human::intro();

$li=new Human();

$li->eat();

?>