Re: [PHP] Class Constants

2011-04-13 Thread Richard Quadling
On 13 April 2011 19:04, Floyd Resler wrote: > That didn't quite work.  Here's what I did: > $const=$argv[1]; > $value=email::$const; > > When I run it I get an "Access to undeclared static property" error. > > Thanks! > Floyd > > On Apr 13, 2011, at 1:16 PM, Richard Quadling wrote: > >> On 13 Apri

Re: [PHP] Class Constants

2011-04-13 Thread Floyd Resler
David, That worked great! Thanks! Floyd On Apr 13, 2011, at 2:25 PM, David Harkness wrote: > On Wed, Apr 13, 2011 at 11:04 AM, Floyd Resler wrote: > >> That didn't quite work. Here's what I did: >> $const=$argv[1]; >> $value=email::$const; >> > > Instead try this: > > $const = $argv

Re: [PHP] Class Constants

2011-04-13 Thread David Harkness
On Wed, Apr 13, 2011 at 11:04 AM, Floyd Resler wrote: > That didn't quite work. Here's what I did: > $const=$argv[1]; > $value=email::$const; > Instead try this: $const = $argv[1]; $reflector = new ReflectionClass('email'); $value = $reflector->getConstant($const); David

Re: [PHP] Class Constants

2011-04-13 Thread Floyd Resler
That didn't quite work. Here's what I did: $const=$argv[1]; $value=email::$const; When I run it I get an "Access to undeclared static property" error. Thanks! Floyd On Apr 13, 2011, at 1:16 PM, Richard Quadling wrote: > On 13 April 2011 17:45, Floyd Resler wrote: >> I'm doing some testing fro

Re: [PHP] Class Constants

2011-04-13 Thread Richard Quadling
On 13 April 2011 17:45, Floyd Resler wrote: > I'm doing some testing from the command line and would like to be able = > to pass along a constant from a class.  For example: > php emailTest.,php OrderConfirmation > > OrderConfirmation is a constant in a class.  Is there any way I can take = > the

Re: [PHP] Class constants

2010-04-20 Thread Nathan Rixham
Gary . wrote: > On Mon, Apr 19, 2010 at 3:12 PM, Ashley Sheridan wrote: >> On 19 April 2010 14:24, Gary wrote: > >>> Okay. Why not? > ... >> Class constants must be defined with static values, not variables. They are >> constants after all! If they relied on the value of a variable, surely that

Re: [PHP] Class constants

2010-04-19 Thread David Harkness
On Mon, Apr 19, 2010 at 7:25 AM, Peter Lind wrote: > Per the PHP manual: "The value must be a constant expression". Is > something that depends on other classes, variables or functions > constant? > When I came up against this problem myself, I read "a constant expression" to mean "an expression

Re: [PHP] Class constants

2010-04-19 Thread Adam Richardson
On Mon, Apr 19, 2010 at 10:25 AM, Peter Lind wrote: > On 19 April 2010 16:18, Gary . wrote: > > On Mon, Apr 19, 2010 at 2:37 PM, Peter Lind > wrote: > >> On 19 April 2010 14:24, Gary wrote: > >>> On Mon, Apr 19, 2010 at 10:36 AM, Peter Lind wrote: > > > So no, you shouldn't be able to do t

Re: [PHP] Class constants

2010-04-19 Thread Peter Lind
On 19 April 2010 16:18, Gary . wrote: > On Mon, Apr 19, 2010 at 2:37 PM, Peter Lind wrote: >> On 19 April 2010 14:24, Gary wrote: >>> On Mon, Apr 19, 2010 at 10:36 AM, Peter Lind wrote: > So no, you shouldn't be able to do that. >>> >>> Okay. Why not? >> >> Hate to ask, but did you at any po

Re: [PHP] Class constants

2010-04-19 Thread Gary .
On Mon, Apr 19, 2010 at 3:12 PM, Ashley Sheridan wrote: > On 19 April 2010 14:24, Gary wrote: > > Okay. Why not? ... > Class constants must be defined with static values, not variables. They are > constants after all! If they relied on the value of a variable, surely that > would mean that their

Re: [PHP] Class constants

2010-04-19 Thread Gary .
On Mon, Apr 19, 2010 at 2:37 PM, Peter Lind wrote: > On 19 April 2010 14:24, Gary wrote: >> On Mon, Apr 19, 2010 at 10:36 AM, Peter Lind wrote: >>> So no, you shouldn't be able to do that. >> >> Okay. Why not? > > Hate to ask, but did you at any point consider to read the PHP docs on > this? The

Re: [PHP] Class constants

2010-04-19 Thread Ashley Sheridan
On Mon, 2010-04-19 at 14:37 +0200, Peter Lind wrote: > On 19 April 2010 14:24, Gary . wrote: > > On Mon, Apr 19, 2010 at 10:36 AM, Peter Lind wrote: > >> On 19 April 2010 10:30, Gary wrote: > >>> Should I be able to do this: > >>> > >>> class X > >>> { > >>> const FOO = 'foo'; > >>> const FOOBA

Re: [PHP] Class constants

2010-04-19 Thread Peter Lind
On 19 April 2010 14:24, Gary . wrote: > On Mon, Apr 19, 2010 at 10:36 AM, Peter Lind wrote: >> On 19 April 2010 10:30, Gary wrote: >>> Should I be able to do this: >>> >>> class X >>> { >>>  const FOO = 'foo'; >>>  const FOOBAR = X::FOO . 'bar'; >>> >>> ... >>> } > >> So no, you shouldn't be able

Re: [PHP] Class constants

2010-04-19 Thread Gary .
On Mon, Apr 19, 2010 at 10:36 AM, Peter Lind wrote: > On 19 April 2010 10:30, Gary wrote: >> Should I be able to do this: >> >> class X >> { >>  const FOO = 'foo'; >>  const FOOBAR = X::FOO . 'bar'; >> >> ... >> } > So no, you shouldn't be able to do that. Okay. Why not? -- PHP General Mailing L

Re: [PHP] Class constants

2010-04-19 Thread Peter Lind
On 19 April 2010 10:30, Gary . wrote: > Should I be able to do this: > > class X > { >  const FOO = 'foo'; >  const FOOBAR = X::FOO . 'bar'; > > ... > } > > ? > > Because I can't. I get "syntax error, unexpected '.', expecting ',' or > ';'". I assume this is because the constants are like statics

Re: [PHP] class constants

2006-03-07 Thread Arnaldo Gandol
getConstants()); ?> Thank you, I've try this above and works, I hadn't seen the message below. Excuse my english. On 3/7/06, Jared Williams < [EMAIL PROTECTED]> wrote: > > > > > > Hi, > > > > ReflectionClass > > > > getConstant > > getConstants > > hasConstant > > > > http://www.ren.dotgeek.org

Re: [PHP] class constants

2006-03-07 Thread Arnaldo Gandol
I've try this with no successful results. the constant rr and gg were not in the array $ee. $value) echo $key." => ".$value.""; ?> On 3/7/06, Jared Williams <[EMAIL PROTECTED]> wrote: > > > Hi, > > ReflectionClass > > getConstant > getConstants > hasConstant > > http://www.ren.dotgeek.org/c

RE: [PHP] class constants

2006-03-07 Thread Jared Williams
Hi, ReflectionClass getConstant getConstants hasConstant http://www.ren.dotgeek.org/classbrowser/class.php?class=ReflectionClass Jared > -Original Message- > From: Arnaldo Gandol [mailto:[EMAIL PROTECTED] > Sent: 07 March 2006 21:03 > To: php-general@lists.php.net > Subject: [PHP] c

Re: [PHP] class constants

2006-03-07 Thread Chris
Shaunak Kashyap wrote: Constants aren't per class, they are per system. Whether you define them in a class or not won't change this. You can list all constants using http://www.php.net/manual/en/function.get-defined-constants.php Actually, PHP5 allows constants per class, aka class cons

RE: [PHP] class constants

2006-03-07 Thread Shaunak Kashyap
> > Constants aren't per class, they are per system. Whether you define them > in a class or not won't change this. > > You can list all constants using > http://www.php.net/manual/en/function.get-defined-constants.php > > Actually, PHP5 allows constants per class, aka class constants. I think

Re: [PHP] class constants

2006-03-07 Thread Chris
Arnaldo Gandol wrote: how can I to iterate the class constant without knowing their names?, I've reviewed the Class/Object Functions and Reflexion and nothing, I dont want to use static class variables, can any one help. Constants aren't per class, they are per system. Whether you define them

Re: [PHP] Class constants

2005-07-28 Thread Jochem Maas
Marcus Bointon wrote: I'm not sure if this is a bug or a feature, but it seems you can't use class constants to set default values for class properties. You can, however, use them for default values for method params, e.g.: class foo {} ^--- er. const BAR = 100; private $