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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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,
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
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.
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
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
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
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
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.
?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:
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 =
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
26 matches
Mail list logo