Thoughts caused by protected in php

不言
Release: 2023-03-25 07:30:02
Original
3278 people have browsed it

This article mainly introduces the thoughts about protected in php. It has certain reference value. Now I share it with you. Friends in need can refer to it

protected: is protected Protected, it can only be used inside the class and inherited classes, and cannot be used outside the class. In other words, it is the use of $this-> or $parent::;

to call the parent class: variable in the subclass and parent class$this-> Variable name, if there is this variable in the subclass, the variable in the subclass will be called, if not, the variable in the parent class will be called ; Method call: $this->Method name();If there is this method in the subclass, the method in the subclass will be called. If not, the method in the parent class will be called.

parent:: in the class always calls the method in the parent class and does not call the attribute.


The above is the detailed content of Thoughts caused by protected 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
Popular Tutorials
More>
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!