setting PHP Server Header


you get warning in your browser that the js data are transfered as MIME type text/xs-javascript,
Or you have delared in your html meta:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

but you can still not read utf-8 charactor in your browser.

It is all because your server header is sending in a different definition.
I am using a lot Appache and PHP. So the definition in your html meta is not enough for a UTF-8

I need to set the Server header manually. It is possible to change the setting in Appache config file.
But mostly you don’t have the possibility to access this file.
In PHP you can set the server header with “header()” function.

For example:

// set server content header
header('Content-Type: text/html; charset=UTF-8');

at the very first line of your php file. If the php file has include, you should
insert the header call at the very first line of your include file so that this
Server header modification always take effect first.



About yingding wang
i am looking forward to innovation in IT and Robotics

Comments are closed.

%d bloggers like this: