I am getting the following error when using the code below the error. can you tell me what i am doing wrong?
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in D:\dev\TESTCASE_classes_layout\main.class.php on line 18
Here is the code I use :
<?php
include('test_class1.php');
include('test_class2.php');
include('test_class3.php');
class Main_Class{
protected $test_class1;
protected $test_class2;
protected $test_class3;
private $objects_array = array();
public function Main_Class(){
$this->test_class1 = new Test_Class1();
$this->objects_array['test_class1'] = $this->test_class1;
$this->test_class2 = new Test_Class2();
$this->objects_array['test_class2'] = $this->test_class2;
$this->test_class3 = new Test_Class3();
$this->objects_array['test_class3'] = $this->test_class3;
}
public function get_Objects(){
return $this->objects_array;
}
}
?>
Here is the code I use for all three test classes. It is exactly the same code only for class name number and the function name number.
<?php
class Test_Class1 extends Main_Class{
function test1(){
return 'hello';
}
}
?>
It has to do with the extending part. Cause when I delete the extending part it works.
Here is my goal:
I am trying to instantiate the classes in this class and extend from it so all classes can call each other without generating another instance of the class.
maybe there is a better way of doing that so if you know that then let me know.