Jump to content

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?

surround the new value of the variable in brackets, and also you don't need the square brackets around T in the date function.

i.e.

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

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();
}

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.