Consider the following situation
class URISplit {
var $REQ_URI;
//some more variables
function __construct($uri) {
//some code
$this->REQ_URI = $uri;
//some code yet again
}
}
and the following
class URIResolve extends URISplit {
//some variables
function __construct($uri) {
//some code
}
}
and another
class PageControl extends URIResolve {
//some variables
function __construct($uri) {
//some more code
}
}
and now the following statement
$page = new PageControl($_SERVER['REQUEST_URI']);
will this statement ensure the proper construction of all classes.
In other words, will constructors of class URISplit and class URIResolve use the string supplied to class PageControl‘s constructor, and do the proper construction.
My Objective is to just create an object of class PageControl and relax and see it do the work. Work means ->
- splitting the URI (done by
class URISplit) - resolving it (where to fetch the data for what is asked i.e. whether its a post, page, news, or anything else) (done by
class URIResolve) - loading appropriate headers, pages, and other page components (done by functions in
class PageControl
Phew! Long question!
You should explicitly call the parent constructor from the child’s one. Take a look at this site for an example.
The reason is that the child class may choose to give the parent constructor some different arguments.
Heck, it’s even possible to have an