插入数据
将单引号(') 前加上\ ,避免数据库插入错误. 相关函数 : addcslashes($str,'\'');
读取数据
乱码
echo '/************addcslashes************/';
$str = 'abcdfegadsf\'asdfasdfa';
echo addcslashes($str,'\'');
echo '/************htmlentities*************/';
$str = 'abcdfe & s ha \'asdfasdfa';
echo htmlentities($str,ENT_NOQUOTES);
echo '/************iconv*************/';
$str = ' ‘ ’ €™â“„”¨¦œ©Ã¡ïï¿ ½ ¾ Ë ª ¢ ¢ ® @ @Weiß, Goldmann, Göbel, Weiss, Göthe, Goethe und Götz € aa';
//change encoding from utf-8 to ascii
echo iconv('utf-8','ascii//TRANSLIT//IGNORE',$str);