Re: Class Constants

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

 



On 13 April 2011 19:04, Floyd Resler <fresler@xxxxxxxxxxxxx> 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 April 2011 17:45, Floyd Resler <fresler@xxxxxxxxxxxxx> 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 value passed on the command line and have PHP figure out which =
>>> constant is equals?
>>>
>>> Thanks!
>>> Floyd
>>
>> In your script ...
>>
>> <?php
>> print_r($argv); // Requires ini setting to set argv and argc.
>> // or
>> print_r($GLOBALS['argv']); //
>> ?>
>>
>> Once you've got the value, you can ...
>>
>> $s_ConstantValue = className::$s_ConstantNameFromCommandLine;
>>
>> sort of thing.
>>
>>
>> --
>> Richard Quadling
>> Twitter : EE : Zend
>> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Or http://uk.php.net/manual/en/function.constant.php

constant('bar::'. $const)


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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