雖然 W3 到有教到點樣改型態,不過佢教既方法「呃」唔到 W3 HTML Validator。
http://juicystudio.com/article/content-negotiation.php#php
IE 係唔支援 application/xhtml+xml,所以要整啲代碼就佢地。
- 代碼: 選擇全部
header('Vary: Accept');
if(strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') || strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== FALSE) {
$contenttype = 'application/xhtml+xml';
} else {
$contenttype = 'text/html';
}
header('Content-Type: '.$contenttype.'; charset=utf-8');
放喺 output 之前就得。
仲有,換咗 application/xhtml+xml 之後 CSS 可能會出問題。不過,我經驗係將全部 body 變做 html 就得