tired of referencing static variables/constants with 'self ::'

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

 



Does anyone know if it's possible to reference class constants or static variables without having to use 'self::' all the time?

class A {
   const MY_CONSTANT = true;

   public function test() {
      echo self :: MY_CONSTANT; // works
      echo MY_CONSTANT; // doesn't work
   }
}

I don't think it is possible, but why not? Can zend/php make it work? Seems it could since this works:

define('MY_CONSTANT', true);
class A {
   public function test() {
      echo MY_CONSTANT; // works
   }
}

It's just annoying my how much boiler-plate I have to write all the time.

Dante

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