Yesideez Posted April 7, 2009 Share Posted April 7, 2009 This is the error message: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/zeb/public_html/calendar/calendar2.php on line 4 This is the first 10 lines of code: <?php class bigCalendar { public $currentDay = 0; public $currentMonth = 0; public $currentYear = 0; public $previousMonth = null; public $currentMonth = null; public $nextMonth = null; public $arrDays = array('Mon'=>1,'Tue'=>2,'Wed'=>3,'Thu'=>4,'Fri'=>5,'Sat'=>6,'Sun'=>7); Any ideas? Quote Link to comment Share on other sites More sharing options...
9three Posted April 7, 2009 Share Posted April 7, 2009 You repeated current month twice. PS. Your attributes need to be set to private Quote Link to comment Share on other sites More sharing options...
premiso Posted April 7, 2009 Share Posted April 7, 2009 To set a variable to a default value, this needs to be done in the constructor. You cannot do it like you are doing. <?php class bigCalendar { public $currentDay, $currentMonth, $currentYear; // etc.. public function __construct() { $this->currentDay = 0; $this->currentMonth = 0; // etc.. } Quote Link to comment Share on other sites More sharing options...
9three Posted April 7, 2009 Share Posted April 7, 2009 He doesn't have to. He can start messing around with each variable as he uses them in each method. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 7, 2009 Share Posted April 7, 2009 Anyway, the error is because you are using php5 syntax on a php4 system. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Author Share Posted April 7, 2009 Even this gives the same error message: class cal { public $currentDay=0; } Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Author Share Posted April 7, 2009 Tried adding it into the __construct: <?php class bigCalendar { public $currentDay,$currentMonth; public function __construct() { $this->currentDay = 0; $this->currentMonth = 0; } And still getting this: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/zeb/public_html/calendar/calendar2.php on line 4 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 7, 2009 Share Posted April 7, 2009 You are going to get that error as long as you try to use php5 syntax on a php4 system. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Author Share Posted April 7, 2009 ...and what is the syntax of PHP4? Quote Link to comment Share on other sites More sharing options...
premiso Posted April 7, 2009 Share Posted April 7, 2009 <?php class cal { var $currentMonth = 0; var $currentYear = 0; function cal() { echo 'constructor'; } } Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Author Share Posted April 7, 2009 Anyone please? Quote Link to comment Share on other sites More sharing options...
premiso Posted April 7, 2009 Share Posted April 7, 2009 Since you did not see that I posted the correct PHP 4 syntax: OOP PHP4 Read up more on it at the PHP Manual. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Author Share Posted April 7, 2009 Sorry - don't know how I missed that! I've checked my web hosting and they have versions 4 and 5 so I've submitted a ticket asking if they can enable PHP5 for me. I use PHP5 at work and never thought that could be why mine wasn't working! Thanks Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 7, 2009 Share Posted April 7, 2009 The end of life of php4 was more than one year ago. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Author Share Posted April 7, 2009 Funny thing is - I thought I was on PHP5 until now! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.