Re: [PHP] Class Constant PHP 5

2005-12-12 Thread Jochem Maas
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

Re: [PHP] Class Constant PHP 5

2005-12-08 Thread Jochem Maas
Jay, gonna have to correct you on this lot (sorry ;-) Jay Blanchard wrote: [snip] is there a way to dynamically define a class constant during runtime in PHP 5? for example I would like to achieve the result of something like: class Example { const FOO = bar(); } However this

RE: [PHP] Class Constant PHP 5

2005-12-08 Thread Jay Blanchard
[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 :-)

Re: [PHP] Class Constant PHP 5

2005-12-07 Thread Stephen Leaf
Dynamically setting a constant would break the very rule of it being a constant in the first place. a constant is something that does not change it cannot be dynamic. On Wednesday 07 December 2005 12:00, Jeffrey Sambells wrote: is there a way to dynamically define a class constant during

RE: [PHP] Class Constant PHP 5

2005-12-07 Thread Jay Blanchard
[snip] is there a way to dynamically define a class constant during runtime in PHP 5? for example I would like to achieve the result of something like: class Example { const FOO = bar(); } However this would obviously give a parse error. I know it is possible with variables but I

Re: [PHP] Class Constant PHP 5

2005-12-07 Thread comex
It would be foolish (and would fail anyhow) to do something like this; Nope. :P ?php define(RANDOM, rand(5,12)); var_dump(RANDOM); ? int(12) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Class Constant PHP 5

2005-12-07 Thread Jay Blanchard
[snip] It would be foolish (and would fail anyhow) to do something like this; Nope. :P ?php define(RANDOM, rand(5,12)); var_dump(RANDOM); ? int(12) [/snip] Wow, that should fail. But you did have use var_dump() to get it, which may be slightly counter-intuitive. I just did this function

RE: [PHP] Class Constant PHP 5

2005-12-07 Thread Jay Blanchard
[snip] Wow, that should fail. But you did have use var_dump() to get it, which may be slightly counter-intuitive. I just did this function realRand($x){ $x = $x * rand(5,10); return $x; } define(RANDOM, realRand(1.2)); var_dump(RANDOM); and it returns floats. Well, I'll be

Re: [PHP] Class Constant PHP 5

2005-12-07 Thread Roman Ivanov
Stephen Leaf wrote: Dynamically setting a constant would break the very rule of it being a constant in the first place. Did you say something about my Java? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Class Constant PHP 5

2005-12-07 Thread Jeffrey Sambells
The point was more that the constant's value is 'defined' at the beginning of the script, and is constant and non changing throughout the entire execution of the script. But I was looking for a way to give it a namespace inside a class rather than just defining in in the global scope so that I