what is class in php
The class is a programming block structure contains its own properties and methods to process the domain functionalities. We can create instances to a class to access its properties and method. The following example code shows a Car() class containing the properties and methods. In this example, I have specified access specifier for the class properties and methods. These access specifiers are used to restrict the visibility of class properties and methods.
- Class is a programmer-defined data type, which includes local methods and local variables.
- First, we have to define a PHP class, where the class-name should be the same as the filename.
Example Of Class
class Car{
private $carModal = "Alto";
public function getModal() {
return $this->carModal;
}
}