Monday 3 May 2021

Php: How to define a class?

Class defines a prototype of an object. Class is defined using 'class' keyword followed by class name, class definition is surrounded in curly braces.

 

Syntax

class ClassName{

        

}

 

Example 1

class Employee{

        

}

 

Example 2

class UserUtil{

        

}

 

As per the convention,

a.   Class name starts with a capital letter and every 1st character of subsequent words also a capital letter.

b.   Define each class in a separate file

Previous                                                    Next                                                    Home

No comments:

Post a Comment