I have a main class in index.php
:
class myClass {
public function lorem() {
include_once 'extendClass.php';
}
public function __construct() {
$this->lorem();
}
}
// run class
new extendClass();
I need to include_once 'extendClass.php'
within the lorem()
function.
In my extendClass.php
file, I extend the class function with:
class extendClass extends myClass {
public function lorem(){
echo "foo bar";
parent::lorem();
}
}
When I use new extendClass()
in index.php
, I get an error because the include_once()
is not triggered. What's the solution to this puzzle?
Note: include_once()
must be within myClass
.