在PHP中可以通過在PHP文件頭部添加“header("Content-type: text/html; charset=utf-8");”語句來設(shè)置編碼。
本文操作環(huán)境:windows7系統(tǒng)、PHP7.1版,DELL G3電腦
php頭編碼怎么設(shè)置?
設(shè)置utf編碼的代碼如下:
header("Content-type: text/html; charset=utf-8");
注:通常情況以上代碼放在php頁面的首頁
header() 函數(shù)向客戶端發(fā)送原始的 HTTP 報(bào)頭。
附:
php頁面為gbk編碼
header("Content-type: text/html; charset=gb2312");
php頁面為big5編碼
header("Content-type: text/html; charset=big5");
推薦學(xué)習(xí):《PHP視頻教程》