手机
当前位置:查字典教程网 >编程开发 >php教程 >使用php清除bom示例
使用php清除bom示例
摘要:核心代码functioncheckBOM($filename){global$auto;$contents=file_get_content...

核心代码

function checkBOM ($filename) { global $auto; $contents = file_get_contents($filename); $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) { if ($auto == 1) { $rest = substr($contents, 3); rewrite ($filename, $rest); return ("<font color=red>BOM found, automatically removed.</font>"); }else { return ("<font color=red>BOM found.</font>"); } }else return ("BOM Not Found."); }

php清除莫明输出大法,用于输出图片前把前面所有输出清空

只要在header前连用两个函数,就可以解决...

ob_get_clean(); ob_clean(); header("Content-type: image/jpeg");

附几个好用的BOM检测工具:

BOM检测.zip

使用php清除bom示例1

使用php清除bom示例2

【使用php清除bom示例】相关文章:

使用php的swoole实现高效安全的ftp服务器

PHP中的traits简单使用实例

php中的时间处理

使用PHP的错误处理

使用PHP模拟HTTP认证

PHP SplObjectStorage使用实例

操作Oracle的php类

使用无限生命期Session的方法

php遍历CSV类实例

PHP 反射(Reflection)使用实例

精品推荐
分类导航