I have 2 PHP class that related each other, rather than using __construct, I tryin to using extends to combine these 2 class. But why sub class method cant called from parent class? There’s no either result or error displayed but warning about reach memory limit.
here my example code:
<?php
class Me {
public $you;
public function __construct() {
$this->you = new You;
}
public function Hi()
{
return 'Hi You';
}
public function WhatYouSaid()
{
return $this->you->Me();
}
}
class You extends Me{
public function Me()
{
return 'Yes Me';
}
}
$talk = new You;
print_r($talk->WhatYouSaid());
I received error:
Fatal error: Allowed memory size of xxx bytes exhausted (tried to allocate xx bytes)