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:
test::$a;
Note that a must be preceded by the $ symbol, which is different from the-> symbol!
If you want to call static method B
test::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
parent::b();
When we need to call our own method cs, there are two methods
self::cs();
$this->cs();
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: http://www.ly89.cn/detailB/57.html
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...