💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
1. 静态属性和静态方法             类内访问:**self::方法|属性**  类外访问:**类名::方法|属性** 2. 类常量                                    类内访问:**self::常量名**   类外访问:**类名::常量名** 3. 调用父类的属性和方法          parent::属性|方法 4. 作用域限定符 **4的例子:** ::左边表示的是作用域,右边表示的是访问的成员 例子1: ``` <?php class Apple { public function showColor() { echo 'green'; } } class Banana { public function GetColor() { return Apple::showColor(); } } $banana = new Banana; echo $banana->GetColor();//green ``` 例子2: ``` class Apple { public function showColor() { return $this->color; } } class Banana { public $color='Banana is yellow'; public function GetColor() { return Apple::showColor(); } } $banana = new Banana; echo $banana->GetColor(); //7以下:Banana is yellow //7以上:Fatal error: Uncaught Error: Using $this when not in object context in /usercode/file.php:8 ``` 例子3: ``` class Apple { public function showColor() { echo'1111'; return $this->color; } } class Banana { public $color; public function __construct() { $this->color = "Banana is yellow"; } public function GetColor() { return Apple::showColor(); } } $banana = new Banana; echo $banana->GetColor(); //7以下:111 Banana is yellow //调用GetColor方法执行方法里的return Apple::showColor();但是里面的函数$this代表当前对象而当前对象就是实例化的Bnana //7以上: //Fatal error: Uncaught Error: Using $this when not in object context in /usercode/file.php:9 ```