Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

__construct

<?php
class BaseClass {
    function __construct() {
        print "In BaseClass constructor
";
    }
}

class SubClass extends BaseClass {
    function __construct() {
        parent::__construct();
        print "In SubClass constructor
";
    }
}

class OtherSubClass extends BaseClass {
    // inherits BaseClass's constructor
}

// In BaseClass constructor
$obj = new BaseClass();

// In BaseClass constructor
// In SubClass constructor
$obj = new SubClass();

// In BaseClass constructor
$obj = new OtherSubClass();
?>
Source by www.php.net #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
1+3 =