/** * 普通方法,存在于类内,只有一份 * 静态方法,也是存在于类内,也只有一份 * * 区别在于:普通方法需要对象去调动,需要绑定$this, * 即,普通方法,必须要有对象,用对象来调动 * * 而静态方法,不属于那个对象,不需要绑定$this来调用 * 静态方法是属于类的通过(类名::对应方法名)来调用 * */ class Human { public static $name = 'zhangsan'; public static function cry() { echo '55555<br />'; } public function laught() { echo 'hahahaha'; } public function who() { echo self::$name; } } $m = new Human(); $m->who();
<?php /** * */ class Human { public $name = 'lisi'; public function who() { echo $this->name; } } $a = new Human(); $a->who();