This afternoon, an entry-level PHPER who fell in love with PHP at first sight asked me: what does it mean. I wrote this simple basic tutorial by the way. : Actually, it is a way to call static methods or static variables: Let's say, generally, if we encapsulate a variable or method into a Class, we cannot directly
This afternoon, an entry-level PHPER who fell in love with PHP at first sight asked me: what does it mean. I wrote this simple basic tutorial by the way. : Actually, it is a way to call static methods or static variables: Let's say, generally, if we encapsulate a variable or method into a Class, we cannot directly
This afternoon, an entry-level PHPER who fell in love with PHP at first sight asked me: what does it mean. I wrote this simple basic tutorial by the way. : Actually, it is a way to call static methods or static variables: Let's say, generally, if we encapsulate a variable or method into a Class, we cannot directly call this method or variable. I don't need to talk about anything nonsense. Let's look at the code to explain it.
You cannot directly call variables or classes.
??
If we write this way, an error will be reported immediately: the reason is that the $ itluren variable is not successfully called externally (but it is not because of him), __itluren () method cannot be called correctly, the _ itluren () function is not defined. To work properly, we need to instantiate this Class, which is the same as the next example.
Called after instantiation
$ Itluren ))? 'EMPTY ': 'loving ';?? $ Itluren_class->__ itluren ();???? ???> ??
In this way, we can see the words "Love itluren.com. What is static for? Let's take a look at the following example !!
Static is playing.
??
We use echo (empty (example: $ itluren) separately ))? 'Null ': 'love'. Here, we can only see "love', because: We successfully called $ itluren to introduce a variable, and used example :: __itluren (); an error is indeed reported because the static attribute is not set for the _ itluren () method. Therefore, the call is successful through. How are you doing?
In general, we rarely encounter the static attribute, which is usually used when defining classes. However, this is also a very critical keyword, but exception is important, so we need to be clear. If you still don't understand it, we suggest you do it several times !!
Statement: This article uses BY-NC-SA protocol for authorization | IT passers-
Reprinted please note