I’m puzzled about something and its a little complicated to put down my own code.
BUT I will do my best to explain it.
I have a file that functions like a bootstrap.
At the start of the file I include a settings php with a class called settings.
Directly after it, I instantiate the settings class.
After it i include a php document that will instantiate all other classes in my system.
code:
include('settings.php');
$settings = new Settings();
include('classes.php');
Inside the settings class there is a constructor that will run a number of functions that will set some constance variables for default values.
Now comes my problem.
As example lets say that in the classes.php a class ‘Test’ is instantiated.
That would mean i can extend that class from the settings class.
But when i do that the constructor will run again and get errors that the constance vars are already defined.
My question is… Will php run the construct of the settings class when instantiating the test class?
Regards.
If
Testclass has its own constructor (_constructmethod) then parent constructor will not be invoked unless you call it explicitly from inside child class constructor likeparent::__construct().If
Testclass does not have__constructmethod then parent constructor will be called (if any).