Difference between class static call and scope resolution operator in PHP

jacklove
Release: 2023-04-02 09:58:02
Original
2123 people have browsed it

This article mainly introduces the difference between class static calling and range resolution operators in PHP. Friends in need can refer to it

The specific code is as follows:

who(); // 输出 'child' static::who(); // 延迟静态绑定 是范围解析,不是静态调用 } function who() { echo 'parent
'; } } class ChildClass extends ParentClass { public static $my_static = 'child var '; function who() { echo 'child
'; } } $obj = new ChildClass(); $obj->test(); echo ChildClass::$my_static;//静态调用
Copy after login

The above output

parent

child

child

child var

Summary

The above is the editor’s introduction to the difference between class static calls and range resolution operators in PHP. I hope it will be helpful to you. If you have any questions If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank you all for your support of the php Chinese website!

Articles you may be interested in:

Detailed examples of stack and queue functions implemented by PHP based on arrays

Detailed explanation of error handling and exception handling methods based on PHP7

Explanation of predefined variables for PHP learning

The above is the detailed content of Difference between class static call and scope resolution operator in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!