Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /home/ct33h8azxpia/public_html/wp-content/themes/aquarella-lite/single.php on line 94
PHP Classes - Experts PHP

PHP Classes

Introduction to PHP Classes

Class is an object oriented programming feature. By this, you bind together any data and operations that are performing on it. Class is represented by data properties (variables).

By creating Class, you can separate one type of data from other types of data. For example, you can represent the data of a company’s marketing department and its related operations by a class and represent the data of the sales department and its related operations in the second class. Define the data and its related functions in different classes. By decreasing the complexity of the program decreases.

Syntax

In PHP, class you define using the class keyword. Its simple syntax is being given below.

<?php
class className
{
// Properties & Functions here.....
}
?>

Example

A simple example of creating a class in PHP is being given below.

<?php
class Employee
{
// Property declaration
public $name = "Fred";
// Function declaration
public function emFunction()
{
return $this->name;
}
}
?>