CH14,P272,练习一,编码转化类---不大会应用

来源:互联网 发布:java 键值对 常量 编辑:程序博客网 时间:2024/05/17 06:16
<?phperror_reporting(E_ALL ^E_NOTICE);class changecode{    private $str;    private $input;    private $output;    function __construct($input='',$output='gb2312'){        $this->input = $input;        $this->output = $output;    }    protected function chgcode($str){        if($this->input != ''){            $this->str = iconv($input,$output,$str);        }else{            $this->str = mb_convert_encoding($str,$output);        }    }    function getStr($str){        $this->chgcode($str);        return $this->str;    }    function setInput($input){        $this->input = $input;    }    function setOutput($output){        $this->output = $output;    }    function getInput(){        return $this->input;    }    function getOutput(){        return $this->output;    }}$contents = new changecode('utf8','gb2312');echo $contents ->getStr('下里巴人');?>

0 0
原创粉丝点击