how to write a constrctor in php code example
Example 1: php const
<?php
define('CONSTANT', 'Hello world !');
const CONSTANT = 'Hello world !';
const NEW_CONSTANT = CONSTANT.' And beyond...';
const ANIMALS = array('dog', 'cat', 'ant');
define('ANIMALS', array('dog', 'cat', 'ant'));
?>
Example 2: construtor php
class BaseClass {
function __construct() {
print "In BaseClass constructor\n";
}
}
class SubClass extends BaseClass {
function __construct() {
parent::__construct();
print "In SubClass constructor\n";
}
}