Get the App
SLTechnology News&Howtos  ›  Development  › 

What does php double colon mean?

Shulou Source: shulou.com Published: 2022-06-02 02:43:55 10月04日 Update

This article is about what php double colons mean. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The php double colon is the reference method of the static method and static property in the class, and the double colon is the static reference to the method in the class, that is, it does not need to instantiate the object, but directly references the method in the class through the class name.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

What does the double colon of php mean?

What do two consecutive colons in Php:: mean?

Reference methods for static methods and static properties in the class (two colons (::) are static references to methods in the class; that is, methods in the class are referenced directly through the class name without instantiating the object.

For example:

Class Test {public static $test = 1; public static function test () {}}

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

Static method calls are the same as Test::test (); static method test is called directly

Thank you for reading! This is the end of the article on "what does php double colon mean?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Method static colon meaning instance object attribute two that is content more article class name good practical no article environment computer read Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology macOS vpn Microsoft Redmi