Advertisement
Guest User

PHP enum

a guest
Jul 9th, 2011
961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. class PageSpecial {
  2.     protected $value;
  3.     private static $instances = array();
  4.     protected function __construct($value) {
  5.         $this->value = $value;
  6.     }
  7.     function __toString() {
  8.         return $this->value;
  9.     }
  10.     static function conditions() {
  11.         if (!isset($instances[__FUNCTION__])) {
  12.             $instances[__FUNCTION__] = new self(__FUNCTION__);
  13.         }
  14.         return $instances[__FUNCTION__];
  15.     }
  16.     static function home() {
  17.         if (!isset($instances[__FUNCTION__])) {
  18.             $instances[__FUNCTION__] = new self(__FUNCTION__);
  19.         }
  20.         return $instances[__FUNCTION__];
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement