Re: What is wrong with this code?

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

 



On 28 April 2010 10:57, Gary . <php-general@xxxxxxxxxxxxxxx> wrote:
> On 4/28/10, Jochem Maas wrote:
>>>     >> class Pg_Error
>>>     >> {
>>>        const INTEGRITY_CONST_UNIQUE = '23505';
>>
>> this is a class constant
>>
>>>     >>     private static $errors =
>>>     >>         array(INTEGRITY_CONST_UNIQUE => 'uniqueness constraint
>>>     violated');
> [...]
>> unfortunately you cannot use a classes
>> own
>> constants in the definition of the $errors var
>
> Huh? IWFM. Is it defined in the language that it does not work, or
> might not work depending on the runtime environment? IMO it should
> work (given the declaration order) but I know statics do have a
> tendency (certainly in other laguages) to be somewhat "special".
>

Shouldn't be any problems using a classes constants in the definition
of an array in the same class. However, to avoid possible extra work
down the line, I wouldn't use Pg_Error::YOUR_CONSTANT inside the
class, I'd use self::YOUR_CONSTANT

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>

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