I am misunderstanding how php object references are meant to work. I understand that in php 5 reference assignment is automatic for objects. I understand how reference assignment works for non objects.
I want to pass a reference to an object instance from a method to the calling code and then call a method of that class using the instance reference.
When I attempt this I get :
Fatal error: Call to a member function update_Sessions_For_Schedule() on a non-object in...
I have read through a number of similar SO postings but I am no closer finding why I am unable to do this.
So what I have is:
class Schedule checks with class Time_Tabler that a new schedule can be added to the time table prior to allowing it's creation. So obviously during this process Time_Tabler is instantiated.
I want to access this instance from the php code which instantiated the schedule and then call method update_Sessions_For_Schedule() using that instance.
So I have method get_Checked_Time_Table() in class Schedule :-
I have tried this in two formats:
With explicit reference assignment:
public function &get_Checked_Time_Table(){
global $test_Time_Tabler;
return $test_Time_Tabler;
}
where $test_Time_Tabler is instantiated in an earlier class Schedule method.
which is called by
$tested_Time_Table =& $complete_Schedule->get_Checked_Time_Table();
Without explicit reference assignment:
public function get_Checked_Time_Table(){
global $test_Time_Tabler;
return $test_Time_Tabler;
}
where $test_Time_Tabler is instantiated in an earlier class Schedule method.
which is called by
$tested_Time_Table = $complete_Schedule->get_Checked_Time_Table();
In either case
$tested_Time_Table->update_Sessions_For_Schedule($update_As_Insert);
produces the Fatal error.
I do not understand why the reference is not recognised as being an object of class Time_Tabler thus making it possible to call the method.
Any thoughts welcomed.