[請益] 關於header()

看板PHP作者 (阿雁 < 小弟 ~*)時間17年前 (2008/12/14 21:09), 編輯推噓5(500)
留言5則, 5人參與, 最新討論串1/1
關於header()這個函式 在它之前不能有html或echo… 那如果我是從另一個頁面(已經使用header設定編碼utf-8,且有輸出html) 轉入目前頁面(如表單submit轉入), 這樣會造成錯誤嗎 ? 因為我目前就是在第二個頁面加入 header('Content-type: text/html;charset=utf-8') 結果造成輸出錯誤 Warning: Cannot modify header information - headers already sent by (output started at C:\xxx\xxx.php:1) in C:\xxx\xxx.php on line 2 -- ─────────────────────────────────────── http://s-radio.whyza.net:8000/kusoayan.m3u http://yantyped.blogspot.com <每天更新Pandora專用代理喔! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.110.82.96

12/14 21:14, , 1F
正常應該不會...檢查一下UTF-8 BOM
12/14 21:14, 1F

12/14 22:12, , 2F
真的不行就開緩衝區試試? 開頭加上ob_start();
12/14 22:12, 2F

12/14 22:38, , 3F
BOM會在<?php之前就輸出到瀏覽器,用ob_start擋不住
12/14 22:38, 3F

12/14 23:22, , 4F
php.ini裏面開 output_buffer
12/14 23:22, 4F

12/15 00:04, , 5F
開頭加ob_start做緩衝.把不該出現的空格都刪掉試試看
12/15 00:04, 5F
文章代碼(AID): #19HGMUeQ (PHP)
文章代碼(AID): #19HGMUeQ (PHP)