[PHP] Class Constants

2011-04-13 Thread Floyd Resler
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 value passed on the command line and have PHP figure

Re: [PHP] Class Constants

2011-04-13 Thread Richard Quadling
On 13 April 2011 17:45, Floyd Resler fres...@adex-intl.com 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

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 fres...@adex-intl.com wrote: I'm doing

Re: [PHP] Class Constants

2011-04-13 Thread David Harkness
On Wed, Apr 13, 2011 at 11:04 AM, Floyd Resler fres...@adex-intl.comwrote: 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
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 fres...@adex-intl.comwrote: That didn't quite work. Here's what I did: $const=$argv[1]; $value=email::$const; Instead try this: $const

Re: [PHP] Class Constants

2011-04-13 Thread Richard Quadling
On 13 April 2011 19:04, Floyd Resler fres...@adex-intl.com 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

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 would mean

[PHP] Class constants

2010-04-19 Thread Gary .
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 which can't be initialised by functions etc. but is there

Re: [PHP] Class constants

2010-04-19 Thread Peter Lind
On 19 April 2010 10:30, Gary . php-gene...@garydjones.name 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

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 List

Re: [PHP] Class constants

2010-04-19 Thread Peter Lind
On 19 April 2010 14:24, Gary . php-gene...@garydjones.name 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 to do

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 . php-gene...@garydjones.name 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

Re: [PHP] Class constants

2010-04-19 Thread Gary .
On Mon, Apr 19, 2010 at 2:37 PM, Peter Lind peter.e.l...@gmail.com 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

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 own

Re: [PHP] Class constants

2010-04-19 Thread Peter Lind
On 19 April 2010 16:18, Gary . php-gene...@garydjones.name wrote: On Mon, Apr 19, 2010 at 2:37 PM, Peter Lind peter.e.l...@gmail.com 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

Re: [PHP] Class constants

2010-04-19 Thread Adam Richardson
On Mon, Apr 19, 2010 at 10:25 AM, Peter Lind peter.e.l...@gmail.com wrote: On 19 April 2010 16:18, Gary . php-gene...@garydjones.name wrote: On Mon, Apr 19, 2010 at 2:37 PM, Peter Lind peter.e.l...@gmail.com wrote: On 19 April 2010 14:24, Gary wrote: On Mon, Apr 19, 2010 at 10:36 AM,

Re: [PHP] Class constants

2010-04-19 Thread David Harkness
On Mon, Apr 19, 2010 at 7:25 AM, Peter Lind peter.e.l...@gmail.com 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

[PHP] class constants

2006-03-07 Thread Arnaldo Gandol
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.

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

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 that's

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

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] class

Re: [PHP] class constants

2006-03-07 Thread Arnaldo Gandol
Subject: [PHP] class constants 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.

Re: [PHP] class constants

2006-03-07 Thread Arnaldo Gandol
?php class something { const rr = lala; const gg = ggerer; } $hh = new ReflectionClass('something'); print_r($hh-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:

[PHP] Class constants

2005-07-28 Thread Marcus Bointon
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 {} const BAR = 100; private $thing = self::BAR; function wibble($a =

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