PHP double colon: usage, php colon usage _ PHP Tutorial

Source: Internet
Author: User
In PHP, the double colon: is used, and the php colon is used. PHP double colon: usage, php colon usage a few days ago in Baidu know that someone asked PHP double colon: usage, at that time, his answer was concise, because mobile phone typing was not very convenient. in PHP, double colons: And php colons were used.

A few days ago, I saw someone asking for the use of double colons: In PHP in Baidu. at that time, the answer I gave him was concise because mobile phone typing was not very convenient! Today I suddenly remembered, so here I will summarize the double colons I encountered: usage in PHP!

Class test {static public $ a; static public function B (){}}

If you want to call the static attribute $ a, as shown below:


Note that a must be preceded by the $ symbol, which is different from the-> symbol!

If you want to call static method B


2. when you call attributes or methods of your own class or parent class

First, create a parent class

class test {    public function b() {}}

Create a subclass to inherit the parent class

class tests extends test {    public function cs() {}}

When we need to call Method B of the parent class

When we need to call our own method cs, there are two methods

I have encountered the above two situations. if you have any other situations, please come to Wang yelou's personal blog to add them!

Do you want to get updates from Wang yelou's personal blog every day? Add the public account"Ly89cn", Or scan the QR code below!

This article from Wang yelou's personal blog, this article address:

You are welcome to share this article. For more information, see the source and address of this article.

Baidu saw someone asking for double colon: In PHP in Baidu a few days ago. at that time, his answer was concise because mobile phone typing was not very convenient...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.