您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 字符操作类实例函数

2024/2/26 13:24:28发布26次查看
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 ) );
}
}
$s ='中国';
$os = new string( $s );
echo $os->decode('gbk') ,'';
echo $os->decode('gbk')->encode('md5'),'';
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product