Public access modifier in PHP programming language

By Prem Tiwari in PHP Tutorials. Updated on


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.

Sharing is caring!


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.

You might also like:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.