Assume the following structure:
<?php
class Event_Dates {
public $start_date;
public $end_date;
public function __construct( $start = null, $end = null ){
$this->start_date = $start;
$this->end_date = $end;
}
public function get_start_date(){
return $this->start_date;
}
public function get_end_date(){
return $this->end_date;
}
}
class Event_Times extends Event_Dates
{
public function __construct()
{
parent::__construct();
}
public function get_parent_start_date(){
return $this->start_date;
}
public function get_parent_end_date(){
return $this->end_date;
}
}
?>
Here's my client code:
<?php
$start = "2017-03-12 04:00:00";
$end = "2017-03-12 17:00:00";
$event_dates = new Event_Dates( $start, $end );
$event_times = new Event_Times();
?>
And the tests:
<?php
var_dump( $event_dates->get_start_date() ); // string(19) "2017-03-12 04:00:00"
var_dump( $event_dates->get_end_date() ); // string(19) "2017-03-12 17:00:00"
var_dump( $event_times->get_parent_start_date() ); // NULL
var_dump( $event_times->get_parent_end_date() ); // NULL
?>
As far as I can see, I'm using properties of Inheritance correctly. So why can't I access the parent class properties through my child class?
parent::__construct();makes no sense at the moment