更新时间:2022-05-08 03:29:32
::
用于静态元素,而->
用于实例元素.
::
is for static elements while ->
is for instance elements.
例如:
class Example {
public static function hello(){
echo 'hello';
}
public function world(){
echo 'world';
}
}
// Static method, can be called from the class name
Example::hello();
// Instance method, can only be called from an instance of the class
$obj = new Example();
$obj->world();