This article mainly introduces the difference between class static call and scope resolution operator in PHP, and the friends who need can refer to the following
The specific code looks like this:
<?php//calls this class or parent class with "::" Inside a subclass or class, instead of statically invoking the method, the scope resolution operator. Class ParentClass {public static $my _static = ' parent var '; function test () { self::who ();//output ' parent ' is a range resolution, not a static Call $this->who ();//output ' child ' static::who ();//delay static binding is a range resolution, not a static call} function who () { echo ' parent<br > '; }}class ChildClass extends ParentClass {public static $my _static = "Child var"; function who () { echo ' CHILD<BR&G t; '; }} $obj = new ChildClass (); $obj->test (); Echo ChildClass:: $my _static;//static Call
Above output
Parent
Child
Child
Child Var
Summarize
The above is a small part of the introduction of the PHP class static call and the scope of the resolution operator of the difference between the analysis, I hope that we have some help, if you have any questions please give me a message, small series will promptly reply to you. Thank you very much for the support of PHP Chinese network!
Articles you may be interested in:
PHP array-based implementation of the stack and queue function example detailed
A detailed analysis of error handling and exception handling methods based on PHP7
Examples of pre-defined variables for PHP learning