Jump to content

[SOLVED] Class problem


Yesideez

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/153030-solved-class-problem/
Share on other sites

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..
   }

Link to comment
https://forums.phpfreaks.com/topic/153030-solved-class-problem/#findComment-803743
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/153030-solved-class-problem/#findComment-803782
Share on other sites

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 :D

Link to comment
https://forums.phpfreaks.com/topic/153030-solved-class-problem/#findComment-803836
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.