date() throwing errors?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
uberdragon
Forum Newbie
Posts: 11
Joined: Thu Apr 27, 2006 8:54 am
Location: Farmington, CT

date() throwing errors?

Post by uberdragon »

Hello,

I'm receiving the following error:

Code: Select all

Parse error: syntax error, unexpected '(', expecting ',' or ';' in C:\Inetpub\webtools\errors2\class2.errors.php on line 80
The line it doesn't like is:

Code: Select all

var $errTime = date("[Y-m-d][H:i:s]");
Any ideas? As far as I can tell I'm using the date() function properly....


Thanks!
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

The line before it, is it closed with ; ?
User avatar
uberdragon
Forum Newbie
Posts: 11
Joined: Thu Apr 27, 2006 8:54 am
Location: Farmington, CT

Post by uberdragon »

Yup, all lines above (besides comments of course) were terminated with a ;


I ended up changing the code around a bit so that variable wasn't using the date function, but just holding the date format.

Code: Select all

var $errTime = "[Y-m-d][H:i:s]";
Then later in the program I use that variable with date() to get the current date/time info.

Code: Select all

$errString = date($this->errTime) . $this->errType[$error_type] . '[' . $error_msg . '] (' . $error_file . ' - Line:' . $error_line . ')';
Once I made these changes everything works fine.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

you can't use functions when declaring a class variable. I am pretty sure when declaring class variables you can only use strings, arrays, and possibly (correct me if I am wrong someone) constants. The rest of the stuff do in the construct.
Post Reply