Public access modifier in PHP programming language

By: Prem Tiwari | Last Updated: | In: PHP Tutorials


This is a basic PHP program based on object-oriented programming which explains how to use the public access modifier in PHP with an example and output.

The public modifier is called with the Public keyword before the defined class name. If you have added the public before any class, then that class will be accessible from outside of class.

After this tutorial, your basic concept of Object-oriented programming will be clear.

Public access modifier in PHP programming language

Program Output

The car model is Mercedes.

Liked this program? Do Like & share with your friends.