FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » declaring private variable in class
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: declaring private variable in class [message #175691 is a reply to message #175690] Thu, 20 October 2011 21:20 Go to previous messageGo to previous message
Gregor Kofler is currently offline  Gregor Kofler
Messages: 69
Registered: September 2010
Karma:
Member
Am 2011-10-20 22:56, DavidB meinte:
> Hi:
>
> I created a class and then declared a private variable called today and set it = to today's date:
>
> class someclass
> {
> private $today = date("Y-m-d");
> }
>
> For some reason, it doesn't like it. There is an error message about the parenthesis. Am I not allowed to set a variable = to some function like date or whatever? It didn't complain when I set it = to some string constant like "2011-10-10".

RTFM.

"This declaration may include an initialization, but this initialization
must be a constant value--that is, it must be able to be evaluated at
compile time and must not depend on run-time information in order to be
evaluated"

http://www.php.net/manual/en/language.oop5.properties.php


HTH, Gregor
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: This is a total php newbie question
Next Topic: Queuing at job from within php program?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 08 14:26:30 GMT 2024

Total time taken to generate the page: 0.05425 seconds