Return to Snippet

Revision: 1387
at October 3, 2006 05:14 by ekobudisetiyo


Initial Code
<?php
class constant
{
   var $____x = array();
   function __construct($a = array())
   {
      $this->fromArray($a);
   }

   function __set($name,$val)
   {
      if(!isset($this->____x[$name]))
      {
         $this->____x[$name] = $val;
      }
   }

   function __get($name)
   {
       if(isset($this->____x[$name])) return $this->____x[$name];
   }

   function __isset($name)
   {
      return isset($this->____x[$name]);
   }

   function toArray()
   {
      return $this->____x;
   }

   function fromArray($a = array())
   {
      if(count($a)>0)
      {
         foreach($a as $k => $v) $this->____x[$k] = $v;
      }
   }
}
?>

Initial URL
http://fuselogic.haltebis.com

Initial Description
Usage:

$constant = new constant();
$constant->test = 'abcd';
$constant->test = '1234';
echo $constant->test;  // out put -> 'abcd'

Initial Title
PHP5 Constant Class

Initial Tags

                                

Initial Language
PHP