网站首页 博客 php过滤UTF-BOM
使用方法:
$contents = removeBOM($contents);
函数定义:
//删除内容中的BOM function removeBOM($contents) { $rest = $contents; $charset[1] = substr($contents, 0, 1); $charset[2] = substr($contents, 1, 1); $charset[3] = substr($contents, 2, 1); if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) { $rest = substr($contents, 3); } return $rest; }