Okay, I can see where this is taking you!
Look at this example:
class parentClass {
protected $iniVar;
private function init($init){
foreach($iniVar as $key=>$value){
/*Do something amazing with each iniVar key/value pair*/
}
}
function __construct(){
init();
}
}
class childClass extends parentClass{
function __construct(){
$iniVar = array('key'=>'value'); ///so on....
}
}
This our reasoning!
" I just have to extend the class, initialize protected variables in the constructor, and let the parent class handle the rest" -and believe me if it was that easy many people would be chaining commands in php as much as they do on javascript!
However this what we didn't think:
We are extending the parentClass which means that the parent constructor is executed first, at this point our protected iniVar is not initialized yet.
You can prove this by setting a static variable in the parentClass and displaying and incrementing its value from the parentClass' constructor every time it's called, then try to call the parentClass' constructor from the childClass' constructor. Try reversing the roles 😉 { have fun }