脚本宝典收集整理的这篇文章主要介绍了从header()获取PHP内容类型,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我真正的问题是知道正在使用哪个charset并在必要时仅修改它,而不必重新定义Content-type信息.即如果content-type是application / XMl,请保留它,但更改唯一的charset.
防爆.
Original: Content-type: text/html First: -> set to application/xml. Content-type: application/xml Second: -> set charset. Content-type: application/xml; charset=utf-8 Third: -> set to text/html Content-type: text/html; charset=utf-8
怎么可能?
$headers = headers_list(); // get the content type header foreach($headers as $header){ if (substr(strtolower($header),13) == "content-type:"){ list($contentType,$charset) = explode(";",trim(substr($header,14),2)); if (strtolower(trim($charset)) != "charset=utf-8"){ header("Content-Type: ".trim($contentType)."; charset=utf-8"); } } }
以上是脚本宝典为你收集整理的从header()获取PHP内容类型全部内容,希望文章能够帮你解决从header()获取PHP内容类型所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。