Introduction: This is a detailed page of the scope parsing operator (: :) of PHP. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 339663 'rolling = 'no'>
From: dancing smart Baidu Space
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 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.
<? PHP
Class {
Function example (){
Echo "I am the original function A: Example (). <br/> \ n ";
}
}
Class B extends {
Function example (){
Echo "I am the redefined function B: Example (). <br/> \ n ";
A: Example ();
}
}
// Class A has no object, which will output
// I am the original function A: Example (). <br/>
A: Example ();
// Create a class B object
$ B = new B;
// This will output
// I am the redefined function B: Example (). <br/>
// I am the original function A: Example (). <br/>
$ 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.
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/339663.html pageno: 7.