Exemplo n.º 1
0
 public static function init()
 {
     MCached::connect();
     $key = 'ord::chars::bin';
     $chars = MCached::get($key);
     if (!is_array($chars)) {
         $chrs = $ords = array();
         for ($i = 0; $i <= 0xff; $i++) {
             $char = chr($i);
             $bin = sprintf('%08b', $i);
             $chrs[$i] = $char;
             $ords[$char] = $i;
             $b2cs[$bin] = $char;
             $c2bs[$char] = $bin;
         }
         $chars = array($chrs, $ords, $b2cs, $c2bs);
         MCached::set($key, $chars, 86400);
     }
     self::$chr = $chars[0];
     self::$ord = $chars[1];
     self::$b2c = $chars[2];
     self::$c2b = $chars[3];
 }