i wrote a few days ago about correct way of coding and what im doing at the moment is a caledar..i studied one of the calendar sample codes you have here and i tried to make one of my own and i created an object instead and atlast iv finally finished it but errr..i got stuck on the first part, there is a parse error and no matter how much i look i think i cant find it..plz help me bout this and at the same time i would aprreciate it if u comment on the way i code and created the object so atleast i can improve on my skills....thanks... this is the code
ERROR : Parse error: parse error, expecting `'{'' in G:\Softwares\xampp\xampp\htdocs\sad\calendar.php on line 3
<?php
class calendar(){ <--- this is line 3
var $cur_date; //the current date
var $year;//year the user has chosen to view
var $month;//month the user has chosen to view
var $num_of_days;//number of days in the month chosen
var $month_names = array();//e.g. january
var $valid_years = array();//e.g from 1999 - 2006
var $first_day_week; //determines the first day of the week
var $offset;
function calendar($year = NULL,$month = NULL){ //constructor
$this->setCurrentDate();
$this->setYear($year,$month);
$this->setNumOfDays();
$this->setMonthNames();
$this->setValidYears();
$this->createMonth();
$this->setCalendar();
}
//setters
function setCurrentDate(){
$this->cur_date = getdate();//gets the current date from the server
}
function setYear($year = NULL){
$this->year = ($year == NULL) ? $nCurDate['year'] : $year;
}
function setMonth($month = NULL){
$this->month = ($month == NULL) ? $nCurDate['mon'] : $month;
}
function setNumOfDays(){
$num_of_days = date(t,mktime(0,0,0,$month,1,$year,-1));
}
function setMonthNames(){
$this->monthNames = array(1=>'January',
'Febuary',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December');
}
function setValidYears(){
$this->valid_years = array($year-5,
$year-4,
$year-3,
$year-2,
$yearr-1,
$year,
$year+1,
$year+2,
$year+3,
$year+4,
$year+5);
}
function createMonth(){
if(checkdate($GET['month'],1,$GET['year'] == NULL)){
/it's null meaning there is still no user input on what date therefore the current date will be
displayed /
$year = $cur_date['year'];
$month = $cur_month['mon'];
}
else{
//the user chose a specific date to jump to...
$year = $GET['year'];
$month = $GET['mon'];
if(($year == 1902) || ($year == 2037)){
/mktime does not support before or beyond these dates so e reset nlang nato if mo abot cya
ngadto /
$year = $cur_date['year'];
$month = $cur_month['mon'];
}
}
}
function setCalendar(){
if($month == 12){ // if it si december then...
$prev_month = $month - 1; //meaning november ang iya previous month
$prev_year = $year; //same year ra pro different months so we keep the same year
$next_year = $year + 1; //happy new year
$next_month = 1; //january ni
}
else if($month == 1){ //january ni
$prev_month = 12;
$prev_year = $year - 1;
$next_year = $year;//same year ra kay ang febuary ang next month pro same year rman
$next_month = $month + 1;//febuary
}
else{//other months
$prev_month = $month -1;
$prev_year = $year;
$next_year = $year;
$next_month = $month +1;
}
}
function setFirstDayOfWeek($year,$month){
$this->first_day_week = date(l,mktime(,0,0,0,$month,1,year));
}
function setOffset($num){
$this->offset;
}
//end of setters
function createOffset(){
$this->setOffset($year,$month);
switch($this->getOffset){
case 'Monday':
$temp_offset = 1;
break;
case 'Tuesday':
$temp_offset = 2;
break;
case 'Wednesday':
$temp_offset = 3;
break;
case 'Thursday':
$temp_offset = 4;
break;
case 'Friday':
$temp_offset = 5;
break;
case 'Saturday':
$temp_offset = 6;
break;
default:
$temp_offset = 0;
//note : offset refers to the placement of the date
}
$this->setOffset($temp_offset);
}
//start of getters
function getCurrentDate(){
return $this->cur_date;
}
function getYear(){
return $this->year;
}
function getMonth(){
return $this->month;
}
function getNumOfDays(){
return $this->num_of_days;
}
function getMonthNames(){
return $this->month_names;
}
function getOffset(){
return $this->offset;
}
function getFirstDayOfWeek(){
return $this->first_day_week;
}
}
?>