PHP的"::" "->"和"=>"的区别

1."::" 运算法

  该运算符是调用一个类中的静态成员的方法,如:

 class xxx{

  protected static $instance;

 self::$instance="111";

或者 $this::$instance = "222";

}

2."->"运算符

 该操作符是操作一个类中的成员变量的方法,可以是非static成员变量,如:

 class xxx{

  private $test;

 $this->test="111";

}

3."=>"运算符

 该预算付是数组的key和value映射时使用的运算符。

语法“index => values”,用逗号分开,定义了索引和值。

猜你喜欢

转载自blog.csdn.net/weixin_42545184/article/details/83619890