Talk about the differences between PHP operators '::', '->' and '=>'

青灯夜游
Release: 2023-04-09 07:52:01
forward
5578 people have browsed it

Talk about the differences between PHP operators '::', '->' and '=>'

When I was learning PHP recently, I was a little confused about the three operators "::", "->" and "=>". I will record the learning details here. Let yourself have a stronger grasp.

1."::" Operator

This operator is a method of calling static members in a class, such as:

 class xxx{
  protected static $instance;
 self::$instance="111";
//或者 $this::$instance = "222";
}
Copy after login

2."->"Operator

This operator is a method to operate member variables in a class, which can be non-static members Variables, such as:

 class xxx{
  private $test;
 $this-test="111";
}
Copy after login

3."=>"operator

This budget is used when mapping the key and value of the array operator.

The syntax "index => values", separated by commas, defines the index and value.

Related learning recommendations: PHP programming from entry to proficiency

The above is the detailed content of Talk about the differences between PHP operators '::', '->' and '=>'. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!