I am not new to php, but I find there optional parameters to be a bit ... unique, or maybe its just me.
If I have the following:
class SomeClass{
public function some_method($required_param, $optional_array = array()){
var_dump($optional_array); exit;
}
}
Then do something like:
$test = new SomeClass();
$test->some_method('required', array('optional'));
I get back as a var_dump array(0){}.
I have even tried:
$test = new SomeClass();
$array = array('optional')
$test->some_method('required', $array);
With the same result. Is it because I am already defining that $optional_array is already set as a empty array? I swear this is how you set optional parameters, according to example 3 So why is it sticking with the default empty array? why is it not seeing that hey, this is already set.
var_dump($optional_array);It is not a function.