How to use:
Copy CodeThe code is as follows:
$s = ' China ';
$os = new String ($s);
echo $os->decode (' GBK '), ';
echo $os->decode (' GBK ')->encode (' MD5 '), ';
Code
Copy CodeThe code is as follows:
Class String extends StdClass
{
Private $_val = ';
Public function __construct ($str = ")
{
$this->_val = $str;
}
Public Function __tostring ()
{
return $this->_val;
}
Public function encode ($coder)
{
$coder = ' Encode_ '. $coder;
if (Method_exists ($this, $coder))
{
return $this $coder ();
}else{
return $this;
}
}
Public function decode ($coder)
{
$coder = ' Decode_ '. $coder;
if (Method_exists ($this, $coder))
{
return $this $coder ();
}else{
return $this;
}
}
Private Function Encode_md5 ()
{
return new String (MD5 ($this->_val));
}
Private Function DECODE_GBK ()
{
return new String (Iconv (' GBK ', ' UTF-8 ', $this->_val));
}
}
http://www.bkjia.com/PHPjc/321738.html www.bkjia.com true http://www.bkjia.com/PHPjc/321738.html techarticle How to use: Copy the code as follows: $s = ' china '; $os = new String ($s); Echo $os-decode (' GBK '), '; Echo $os-decode (' GBK ')-encode (' MD5 '), ' ; Code copy Code code is as follows ...