Hello everyone and congrats for your great job, My problem is this: I want to push an object from constructor of a class(Course) to an array property(Courses) of another class(All), without instantiating "All" class.
I tried to do something like this All::array_push($Courses,$this)
Course class
<?php
class Course
{
public $Title;
public $Stream;
public $Type;
public $StartDate;
public $EndDate;
function __construct($title,$stream,$type,$startDate,$endDate)
{
$this->Title = $title;
$this->Stream = $stream;
$this->Type = $type;
$this->StartDate = $startDate;
$this->EndDate = $endDate;
//This is C# way
All.Courses.Add(this);
//I tried to do something like this
//All::array_push($Courses,$this) but not worked
}
}
?>
All class
<?php
class All
{
public static $Students = array();
public static $Assignments = array();
public static $Trainers = array();
public static $Courses = array();
public static $AllCoursesWithTheirStudents = array();
public static $AllCoursesWithTheirTrainers = array();
public static $AllCoursesWithTheirAssignments = array();
public static $AllStudentsWithTheirAssignments = array();
?>