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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.