Page 1 of 1

date() throwing errors?

Posted: Mon Aug 27, 2007 10:17 am
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!

Posted: Mon Aug 27, 2007 10:58 am
by Zoxive
The line before it, is it closed with ; ?

Posted: Mon Aug 27, 2007 1:41 pm
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.

Posted: Mon Aug 27, 2007 1:50 pm
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.