A class is a code template used to generate objects. It is an abstract definition of an object that has properties and methods. It stores data and do tasks.
A class blueprint in PHP looks like this:
class ClassName {
public $var1, $var2;
// NOTE: there is no functionality in the class itself, only declarations
// so you couldn't do something here like: public $var3 = $var1 + $var2;
function __construct() { // This function runs automatically as the object is created
// Connect to database, set cookies, initialize stuff here
}
function __destructor(){
// Runs automatically when unset() is applied to the object. Destructors can't take arguments
}
public function function_name() {
// Function code.
}
}