The difference between class static calls and scope resolution operators in PHP

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.