Hi,

I'm taking a stab at PHP (again) and am getting hung up trying to make
a variable visible to the whole class.

I have two classes in the same file. Class 1 creates an instance of
class2, then calls a method from class2.

...snip of class 1...
$mycalread = new calread($month);
$s = $mycalread->getDateHTML($day, $daysInMonth);
...end snip of class 1...

Class 2 has an array that gets created based on the data passed in the
$month variable. Essentially, I read from a file, and any day that is
listed and is in $month, gets put into an array. That array is
$busydays. I'm trying to make $busydays visible to the whole class,
but only the constructor could view it. I tried to make it class
visible, but now it says it can't access an empty property when I try
to access the page.

...snip of class 2...

class calread{
var $busydays = array();

function calread($curmonth){ // <-- $curmonth is the value $month
getting passed in
// Read file etc....
$this->$busyday[$day] = $ampm; // Value to be stored in index $day of $busyday
// This (above) is where I get the empty property error
}

function getDateHTML($day_in){
$ret = "<td>$busyday[$day_in]</td>";
return $ret;
}

}
... end snip of class 2...

Can someone tell me what I'm doing wrong?

Thanks,
--
Michael Moore
-------------------------------
www.stuporglue.org -- Donate your used computer to a student that needs it.
www.ubuntu-utah.org -- In Utah? Interested in Ubuntu? Come join us.

--------------------
BYU Unix Users Group
http://uug.byu.edu/

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG.
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to