Home > Backend Development > PHP Problem > What does double colon mean in php

What does double colon mean in php

藏色散人
Release: 2023-03-14 19:56:02
Original
4444 people have browsed it

php The double colon is a reference method for static methods and static properties in the class. The double colon is a static reference to the method in the class. That is, there is no need to instantiate the object, and the method in the class is directly referenced through the class name. Make a reference.

What does double colon mean in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

phpWhat does the double colon mean?

What do two consecutive colons in Php: : mean?

Reference methods for static methods and static properties in a class (two colons (::) refer to methods in the class Static reference; that is, there is no need to instantiate the object, and the method in the class is directly referenced through the class name)

For example:

class Test{
     public static $test = 1;
     public static function test(){
    }
}
Copy after login

You can use Test::$ directly without instantiating the object. test to get the value of the $test attribute

The same goes for static method calls Test::test(); Directly call the static method test

Recommended learning: "PHP Video Tutorial

The above is the detailed content of What does double colon mean in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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