Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.



Get Started Now!

Class & Object(php OOPS concept)

OOPS ( Object Oriented Programming System)

Object means a real-world entity such as a pen, chair, table, computer, watch, etc. Object-Oriented Programming is a methodology  to design a program using classes and objects. It simplifies software development and maintenance by providing some concepts.

PHP(Hypertext preprocessor) Programming Patterns:

1)Procedural / Core PHP

2)Object Oriented (Object Oriented method is more popular then Core PHP )

OBJECT ORIENTED Advantage

  • Code more Modular and Reusable
  • Well Organized Code
  • Easier to debug
  • Best for medium to large website projects

Its MVC Frameworks are:-

Codeigniter, laravel, CakePHP, Symfony, Yii, Zend.

  What is Class?

A PHP class is a group of values with a set of operations to manipulate this values. Classes facilitate modularity and information hiding. Classes are used to define a new data type.

What is Object?

 Object is a compound data type,  Values of more than one types can be stored together in a single variable. Object is an instance of  user defined class.

Rules :

  • A variable starts with the $ sign, followed by the name of the variable.
  • A variable name must start with a letter or the underscore character.
  • A variable name cannot start with a number.
  • It can’t be PHP reserved word.
  • You can’t assign computed value inside a class. ($a = 12+5; )
  • You can’t concatenate in the class.(public $name=”ravi”.”Kumar”;)

Example:-

https://gist.github.com/AvinashKumar33/504957d7954d855c3f86134af10c3915

OUTPUT:-

fun1

Example;-

https://gist.github.com/AvinashKumar33/ef54d82d290a3e705635cfacc5173b6a

OUTPUT:-

Employee Detail

Name : ram
Age : 25
Salary : 20000

Related Posts

Error in Laravel:”Invalid Key Supplied”

while trying to log in to your Laravel application, don’t worry. This issue is commonly related to misconfigured or missing keys for Laravel Passport’s OAuth2 authentication system….

Error in Laravel “Davmixcool\MetaManager\MetaServiceProvider Not Found”

When working on Laravel projects, developers often encounter errors during the setup or runtime process. One such error is the “Class ‘Davmixcool\MetaManager\MetaServiceProvider’ not found”, which can occur…

Discover Rewa Effortlessly with Motoshare’s Convenient Bike and Car Rentals

Rewa, the “Land of White Tigers,” offers a unique blend of historical, cultural, and natural attractions that captivate every traveler. To make exploring this charming city more…

Discover Shimoga (Shivamogga) Effortlessly with Motoshare’s Bike and Car Rentals

Nestled in the lush greenery of Karnataka, Shimoga (Shivamogga) is a haven for nature lovers and history enthusiasts. From the roaring Jog Falls to the tranquil forests…

Explore the Spiritual Charm of Mathura with Motoshare’s New Bike and Car Rental Services

Mathura, the birthplace of Lord Krishna, is a city brimming with spirituality, vibrant culture, and historical significance. To make your journey through this sacred city seamless, Motoshare…

Explore Nizamabad Effortlessly with Motoshare’s New Bike and Car Rental Services

Nizamabad, known for its historical monuments, serene landscapes, and rich cultural heritage, is now easier to explore with Motoshare’s newly launched bike and car rental services. Whether…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x