|
Posted by Jayman777 on 10/08/06 00:18
Hello, I am using PHP 4.4.1 and am having problems retrieving an object
from an array of objects and then calling a method on it. Here are two
simple classes that I am using:
class Day
{
var $day;
var $array_of_events;
function Day($in_ts)
{
$this->day = getdate($in_ts);
}
function addEvent($in_event)
{
$this->array_of_events[] = $in_event;
}
}
class Event
{
var $event_id;
var $begin_time;
var $end_time;
var $summary;
var $description;
var $category;
function Event($in_id, $in_begin_time, $in_end_time, $in_summary,
$in_description, $in_category)
{
$this->event_id = $in_id;
$this->begin_time = $in_begin_time;
$this->end_time = $in_end_time;
$this->summary = $in_summary;
$this->description = $in_description;
$this->category = $in_category;
}
}
The problem arises in another class's function with the following code:
$this->array_of_days = array();
for ($i = 1; $i < num_days_in_month + 1; $i++)
{
$this->array_of_days[$i] = new Day(mktime(00, 00, 00, $in_date['mon'],
$i, $in_date['year']));
}
/* Unrelated code */
$day_object = $this->array_of_days[$index];
$day_object->addEvent($event);
The program creates an error on the last line of the last code snippet.
My web host does not print out the error message so I don't know
exactly why it fails. I'm sure it has something to do with getting an
object from an array because I tried to call the addEvent function on a
Day object that was not retrieved from an array and it works fine.
Does anyone have an idea what the problem is? Thank you for any help.
Navigation:
[Reply to this message]
|