My question title may be logically wrong, because I do not know how to explain it :)
Here are example of what I need. I have master classe and two another classes which this masters class creates. This two classes have constructors with parameters and I do not know how to pass this parameters.
class Master {
function __construct() {
$this->setup_settings();
$this->load_classes();
}
public function setup_settings() {
$this->settings['classes'] = array( 'Class_A', 'Class_B' );
}
public function load_classes() {
foreach( $this->settings['classes'] as $class) {
new $class; //Here are problem!
}
}
}
class Class_A {
function __construct( $setiings ) {
$this->settings = $settings;
}
}
class Class_B {
function __construct( $setiings ) {
$this->settings = $settings;
}
}
In this case I have an error:
Warning: Missing argument 1 for Class_A ::__construct()
I understanding why it is. But how to pass parameters to this class in this way (when class names are in array)? When I am creating string and passing it I have an error: class cant be converted to string.