欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

一個(gè)PHP的String類(lèi)代碼

 更新時(shí)間:2010年04月20日 20:04:28   作者:  
PHP String 類(lèi),暫時(shí)只有encode,decode方法
使用方法:
復(fù)制代碼 代碼如下:

$s ='中國(guó)';
$os = new String( $s );
echo $os->decode('gbk') ,'';
echo $os->decode('gbk')->encode('md5'),'';

代碼
復(fù)制代碼 代碼如下:

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 ) );
}
}

相關(guān)文章

最新評(píng)論