Jump to content

Class Member Static Variable Can't Append


JustinK101

Recommended Posts

I have the following simple class:

 

class Settings {
		public static $mysql_datetime_format = "%c/%e/%Y %l:%i %p " . date("[T]");
}

 

And referencing like:

 

echo Settings::$mysql_datetime_format;

 

But, I am getting the error: Parse error: syntax error, unexpected '.', expecting ',' or ';'.

 

Why is this invalid?

You can't have a function in a class variable declaration.

 

This one has bugged me since it came on, but for the life of me I couldn't put my finger on what was wrong with it, if your right Ignace (which I don't doubt you are)

 

Do I feel stoopid - or what, doh..

 

Rw

You can't have a function in a class variable declaration.

 

This one has bugged me since it came on, but for the life of me I couldn't put my finger on what was wrong with it, if your right Ignace (which I don't doubt you are)

 

Do I feel stoopid - or what, doh..

 

Rw

 

stoopid, no - unexperienced, maybe ;) PHP != Java

 

You can't do this for example in PHP:

 

public class SomeJavaClass {
     private SomeJavaClass parent = new SomeJavaClass();
}

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.