I'm new to OO, so please be patient. :p What is it called when one object contains another?
Like this:
$calendarYear->january = new Month();
Would "$calendarYear->january" be considered a 'child object' of the "$calendarYear" object?
One more question along these lines...
Is there a way that the "$calendarYear->january" object can access the attributes of it's 'parent' object, "$calendarYear"? I wish I could do the following....
class CalendarYear
{
public $january = NULL; // Month object
public $num = 2007;
public function __construct()
{
$this->january = new Month();
}
}
class Month
{
public function showYear()
{
return $parent->num;
}
}
$calendarYear = new CalendarYear();
echo $calendarYear->january->showYear();
Where "january" can access "calendarYear->num" using $parent->num, outputting "2007". Alas, the magic "$parent" does not exist. Any advice for a OO newb?
Thanks!