Description of the meaning of the range resolution operator (: :) of PHP. Today I see several symbols about PHP. One is @, which is added before a variable to suppress the error reported by the PHP interpreter. that is to say, the error is not displayed even if an error occurs. There are also several symbols about PHP today. One is @, which is added before a variable to suppress the error reported by the PHP interpreter. that is to say, the error is not displayed even if an error occurs.
There is also a more important symbol PHP's range parsing operator (::)
Functions in the category class or functions and variables in the base class are very useful without declaring any instances. The operator is used in this case.
The code is as follows:
Class {
Function example (){
Echo "I am the original function A: example ().
\ N ";
}
}
Class B extends {
Function example (){
Echo "I am the redefined function B: example ().
\ N ";
A: example ();
}
}
// Class A has no object, which will output
// I am the original function A: example ().
A: example ();
// Create a class B object
$ B = new B;
// This will output
// I am the redefined function B: example ().
// I am the original function A: example ().
$ B-> example ();
?>
The above example calls the function example () of Class A, but there is no object of Class A, so you cannot use $ a-> example () or call example () in a similar way (). Instead, we call example () as a class function, that is, it is called as a class function, rather than any object of the class.
There are class functions, but no class variables. In fact, there is no object at all when calling a function. Therefore, a class function can use no objects (but local or global variables can be used), and $ this variable is not used at all.
In the above example, class B redefined the function example (). The original defined function example () in Class A will be blocked and will no longer take effect unless the: operator is used to access the example () function in Class. For example, A: example () (in fact, it should be written as parent: example (). The next chapter introduces this content ).
In this case, the current object may have an object variable. Therefore, you can use $ this and object variables within the object function.
Bytes. One is @, which is added before a variable to suppress the error reported by the PHP interpreter. that is to say, the error is not displayed even if an error occurs. Another one...