Would this be considered a good way to make use of a parent class's method through a child class?
parent::__construct($url); //set $html //do something with $html parent::__construct($new_url); //overwrite existing $html //do something with $html
preguntado el 08 de enero de 11 a las 19:01
Things that go into the constructor generalmente aren't supposed to change during the lifetime of the object. The constructor has a very special purpose. It is called once and only once per object, when the object is created. You shouldn't just keep calling it like any other method, even if PHP allows you to do it.
Also, I assume your "child" code is in the child's constructor? (If not, it's bad practice to call the parent's constructor anywhere in the child except the child's own constructor.)
It's probably neater to destroy the old object and create another one with the new
$url. That's how constructors are supposed to be used.