PHP检查字符串编码和转化编码
<?php
$title = 'abc'; $encode = mb_detect_encoding($title, array('ASCII','UTF-8','GB2312','GBK','BIG5')); echo $encode; echo '<br>'; if ($encode != 'UTF-8'){ $title = iconv($encode,'UTF-8',$title); } echo $title; echo '<br>'; $encode = mb_detect_encoding($title, array('ASCII','UTF-8','GB2312','GBK','BIG5')); echo $encode; echo '<br>';