Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date format and class errors

Status
Not open for further replies.

webdev007

Programmer
Sep 9, 2005
168
Trying to add a var date instead of hard coded date
// this hard coded format works
$cal->addEvent('example Event 2', 2007, 12, 3, '
// trying to make the date a variable (here is today)
//For test purpose I broke the requested date format in three pieces
// Add event on current day
$b = date("Y").',';
$c = date("m").',';
$d = date("d").',';
$a=$b.$c.$d;
// this is line 28
$cal->addEvent('example Event', $a, ' //echo" $a";

// if I echo the result as $a, then the format is the good one

but some errors comes from the class as follow:
<<<
Warning: Missing argument 4 for calendar::addEvent(),
called in C:\ xxxxx on line 28 and defined in C:\xxxxx cal.class.php on line 155
AND
Warning: Missing argument 5 for calendar::addEvent(),
called in C:\xxxxx on line 28 and defined in C:xxxx cal.class.php on line 155

// this is the class section
<<<
// Add an event
public function addEvent($eventTitle, $eventYear, $eventMonth, $eventDay, $eventLink) {
$this->events[$eventYear][$eventMonth][$eventDay] = array( 'event_title' => $eventTitle, 'event_link' => $eventLink);
}

So how could I transform this line 28 to accept a date variable instead of hard coded date?
 
the arguments for the class method include year, month and date. you cannot simply substitute a string variable for some genuine arguments. by all means pass in variables, but do so as one variable for each argument.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top