Re: Class Constant PHP 5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jay Blanchard wrote:
[snip]
it doesn't fail and is not imho foolish by definition ... the value of the
constant,
although changing stays the same for the duration of the request,

IIRC Rasmus himself once mentioned that it can be useful to be able to set
a constant to a 'dynamic' value like this - nuff said really :-)
[/snip]

Thanks for the education there Jochem, I'd forgotten about const mostly
because I am in the habit of declaring private static variables and using
get and set methods for this kind of thing because I do a lot of C++ work
too and the theory holds up in both languages. And it is correct in the fact
that a class constant cannot contain a function (as I hadn't clearly stated
earlier) as the OP had requested, the syntax would fail.

true - although the classkit extension would allow you to hack the class and set the
constant to a return value of a function. doing it your way would be
_much_ better though :-)


I guess that I am old school enough (I see John Nichel's hands racing to the
keyboard now!) that expect a constant to be just that. The concept of a
changing constant is what we would normally call a variable. I suppose that

but a constant doesn't change through out a single request, only between requests.
as far as the script is concerned the value doesn't ever change (given the 'share nothing'
principle). one reason for using constants in compiled code is so that you can change
behaviour of code at compile time no? well a constant as follows in php ammounts to the same:

define('SOME_ENV_THINGY',	getMyEnvVal());

only compiling is done a little more often.

a holy war could ensue over this. In the end a class constant is constant

your in a fighting mood heh ;-)
given that windows is the spawn of satan ... isn't a crusade started
by a windows shop a little contradictory ;-)


and its visibility is public.
For the OP I found the following manual page;

http://us2.php.net/manual/en/language.oop5.constants.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux