In this section, we will create a base class called base.php
that all of our classes will inherit.
1. Let's start by creating a new file called
base.php
, and placing it in the classes folder inside of the working directory (/Library/Webserver/Documents/verge/classes/base.php
)2. Create an abstract class with a
__construct
function inbase.php
. On__construct
of the object, let's take$type
as an option, and set it to a protected variable also called$type
.<?php abstract class Base { protected $type; public function __construct($type) { $this->type = $type; } }
3. In order to facilitate the getting and setting of variables in our classes later, let's add the
__get()
and__set()
functions right after the__construct
function.<?php abstract class Base { protected $type; public function __construct($type) { $this->type = $type; } public function __get($property) { return $this->$property; } public function __set($property, $value...