See a few symbols about PHP today. One is @, this is added to the front of a variable, to suppress the PHP interpreter error, that is, even if the error is not displayed.
There is also a more important symbol for PHP's range resolution operator (::)
It is useful to access functions in a class or functions and variables in a base class without declaring any instances. and the:: operator is used for this case.
Copy the Code code as follows:
Class A {
function Example () {
echo "I am the original function a::example ().
\ n ";
}
}
Class B extends A {
function Example () {
echo "I am the redefined function b::example ().
\ n ";
A::example ();
}
}
Class A has no objects, which will output
I am the original function a::example ().
A::example ();
Create an object of class B
$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 call example () with the $a->example () or a similar method. Instead, we call example () as a class function, that is, as a function of a class itself, instead of any object of this class.
There are class functions, but there are no classes of variables. In fact, there is no object at all when the function is called. Thus a function of a class can use no object (but local or global variables can be used), and you can not use $this variable at all.
In the example above, class B redefined the function example (). The original defined function example () in Class A is masked and no longer valid unless you use the:: operator to access the example () function in Class A. such as: A::example () (In fact, it should be written as parent::example (), the next chapter describes the content).
For this purpose, it may have object variables for the current object. You can therefore use $this and object variables inside an object function.
The above describes the third party liability insurance scope of the scope of the interpretation of PHP Operator:: The meaning of the analysis, including the third party liability insurance compensation scope of the content, I hope that the PHP tutorial interested in a friend helpful.