在php web手册的侧栏中,addChild方法使用范围解析运算符链接文本::,但在示例中它使用了Arrow运算符.谁能告诉我为什么会这样?
wil*_*aks 113
::用于静态元素,而->例如是元素.
例如:
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();
Run Code Online (Sandbox Code Playgroud)