NYCPHP Meetup

NYPHP.org

[nycphp-talk] Constants interfaces

Michael B Allen ioplex at gmail.com
Tue Sep 2 20:34:16 EDT 2008


How do people feel about the use of Java-ist "Constants" interfaces like:

  interface Sql_Constants
  {

      const SELECT = 1;
      const FROM = 2;
      const WHERE = 3;
      const NOT = 4;
      ....

  }

where the objective is to permit any class that needs these constants
to access them using "self" like:

  require_once 'Sql/Constants.php';

  class Sql_Parser implements Sql_Constants
  {

      public function parse($sql)
      {
          ...
          if ($tokenCode === self::WHERE) {
              ...

Mike



More information about the talk mailing list