I have a method in a singleton class, this class its called from a parent class that is exntended by a child class.
Assume that my classes have been declared and created properly, this is just a quick run down of my coding logic.
class Singleton
{
public function load_sys()
{
$this->something();
}
public function something()
{
$this->load();
}
public function load(){}
}
class Parent
{
public function __construct()
{
$this->sys = Singleton::init();
$this->sys->load_sys();
}
}
class Child extends Parent
{
public function __construct()
{
parent::__construct();
}
}
when I do this I get this error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4296 bytes) in ~~~.php on line 102
what could be causing this?
I think this may not be due to calling a method twice but rather some errors in your code. First of all you are declaring a class with brackets:
should be:
Also, you are declaring a class as
Parentwhich is a reserved word in PHP, so try renaming that first.