Home  >  Article  >  php教程  >  PHP object-oriented access type control

PHP object-oriented access type control

WBOY
WBOYOriginal
2016-08-04 08:57:031260browse

The three modifiers public, protected, and private are the access control mechanisms introduced in php5. By using modifiers, developers can restrict access to members in a class. Literally, these three modifiers are translated into Chinese as public, protected, and private. Let's use code examples to see how public, protected, and private restrict members in a class.


Public access modifier public

The public modifier has no access restrictions on members in the class, and all external members can access members in this class.

<?php
class myclass{
public $public
Statement:
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