Skip to main content

Posts

Showing posts from April 28, 2014

PHP OOP Basics

Following a request by one of my blog readers, this is a very basic php class, actually there are two classes which should help demonstrate how easy it is to use object oriented PHP. Again. should you have any questions please use the comments or write to me using the form on your left ! The second class extends the first class, which basically means inherits all public methods of the first class. <?php //start class class MyClass { //define a property in the class public $prop1 = "I'm a class property!"; //define your functions public function __construct() {  echo 'The class "', __CLASS__, '" was initiated!<br />'; } public function __destruct() {  echo 'The class "', __CLASS__, '" was destroyed.<br />'; } public function __toString() { echo "Using the toString method: "; //or return $this->getProperty(); } public fun...