I see everywhere that you cannot extend multiple classes...i.e.
Class Foo{
//DO FOO STUFF HERE
}
Class Bar{
//DO BAR STUFF HERE
}
Class FooBar extends Foo,Bar{
//DO FOOBAR STUFF HERE
}
That makes sense, but what about:
Class Foo{
//DO FOO STUFF HERE
}
Class Bar extends Foo{
//DO BAR STUFF HERE
}
Class FooBar extends Foo{
//DO FOOBAR STUFF HERE
}
For example, can you have multiple child classes extend the same parent? When I try this, I get an out of memory error, and I tried increasing the memory limit to 512MB but I still get out of memory errors...
What is a way to check memory usage, I mean these are very basic classes, i.e. one public variable, and the Bar class sets the value for the variable in the Foo class...It's a constant thing, but if I wait 15-20 minutes and try again, it is fine. My issue is, this server has 32GB of Ram, and I have even tried the stupid setting memory to 1024M as well.
[Edit Code:]
Class CORE{
public $load;
public $data;
public $models;
public function __construct(){
$this->load=New Loader;
$this->data=New Database;
$this->data->db=New PDO(DSN);
}
public function __dev_email($subject, $message){
$to="[email protected]";
$headers="From: \"Error Checking\" <[email protected]>";
mail($to, $subject, $message, $headers);
}
}
class Loader extends CORE{
public function model($name){
if (file_exists("/var/www/models/".$name.".php")){
require_once("/var/www/models/".$name.".php");
$models[$name]=New $name;
}
}
}
class Error extends CORE{
$this->__dev_email("Bad Database Connection", "Invalid Connection Attempt was made. Please check the configuration.");
}
Keep in mind this is not all of the code, there is an Autoloader, and several different files, but this is a basic version, and I just checked, I am still getting out of memory errors from this.
//DO STUFF HEREimplementations. Like, for example, if you were to instantiate an instance of an object in its own constructor leading to an infinite chain of instantiations...sizeof(Foo) + sizeof(any changes made in Foobar that aren't in Foo)Loaderinstance, theCOREconstructor is called .. which tries to initialize newLoader. Basically: you have endless loop. Also, i really hope that this is not some "mvc framework". We have had 4 such posts in past hour already.