change mime type of output in php

后端 未结 6 1459
时光取名叫无心
时光取名叫无心 2020-12-03 04:32

I\'ve got a php script. Most of the time the script returns html, which is working fine, but on one occasion (parameter ?Format=XML) the script returns XML instead of HTML.<

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 04:39

    header('Content-Type: application/xml; charset=utf-8');
    

    You can add encoding as well in the same line. I added utf-8, which is most common.

提交回复
热议问题