It compiles correctly but I don't get any value on $datum->day, it's empty. Maybe it's because you can't pass a value from a class into another class. Maybe I must put all in the same class, but I don't know if it's possible to create a new operator in a class.
$i has the value of 1 to 31 for the days in a month, it's in a loop. So you compare a value with $i, when they are equal, the value is selected. So when it is today's date, 26, it will loop until 26 == $i. I want ($datum->day == $i) but $datum->day is empty so it prints/selects 'day' instead.
I tried print_r($datum) and it prints out :
datum Object ( [month] => 7 [day] => 26 [year] => 2010 )
Here is the problem:
Code: Select all
class datum {
var $month;
var $day;
var $year;
function datum($umonth,$uday,$uyear)
{ //$today_m = date("n"), $today_d = date("d"), $today_y = date("Y")
$this->month = $umonth;
$this->day = $uday;
$this->year = $uyear;
}
}
$datum = new datum(date("n"), 26,date("Y"));
print_r($datum); //this works fine
class tc_calendar
{
//write the select box of days
function writeDay(){
echo("<select name=\"".$this->objname."_day\" id=\"".$this->objname."_day\" onChange=\"javascript:tc_setDay('".$this->objname."', this[this.selectedIndex].value, '$this->path');\" class=\"tcday\">");
echo("<option value=\"00\">Day</option>");
for($i=1; $i<=31; $i++)
{
$selected = ((int)$this->day == $i) ? " selected" : "";
echo("<option value=\"".str_pad($i, 2 , "0", STR_PAD_LEFT)."\"$selected>$i</option>");
}
echo("</select> ");
echo $datum . " " . $i;
} //end function
} //end class
$datum is empty and also $datum->day. Can I pass the value of the new operator into the class tc_calendar?