- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯(lián)網(wǎng)協(xié)會(huì )理事單位
- 安全聯(lián)盟認證網(wǎng)站身份V標記
- 域名注冊服務(wù)機構許可:滇D3-20230001
- 代理域名注冊服務(wù)機構:新網(wǎng)數碼
最近更新主題的時(shí)候,使用了 wp_redirect() 函數來(lái)做一個(gè)頁(yè)面跳轉,沒(méi)想到出現了“Warning: Cannot modify header information – headers already sent”的錯誤提示:
搜索了下,php中使用重定向跳轉時(shí),“Warning: Cannot modify header information – headers already sent by (output started at…”是常見(jiàn)的錯誤提醒,出現該錯誤的原因是跳轉函數前有包括回車(chē)、空格、換行的輸出,解決方法是使用ob_start()函數打開(kāi)緩沖區,使用跳轉前的輸入進(jìn)入緩沖區而不會(huì )立即輸出,避免這個(gè)錯誤提醒。
如果是 WordPress 使用 wp_redirect() 函數導致的這個(gè)問(wèn)題,在當前主題的 functions.php 文件中添加以下函數即可:
/** * 解決 wp_redirect()導致的 Warning: Cannot modify header information 問(wèn)題 * http://www.tjdsmy.cn/wp_redirect-Cannot-modify-header-information.html */function cmp_do_output_buffer() { ob_start();}add_action('init', 'cmp_do_output_buffer');
售前咨詢(xún)
售后咨詢(xún)
備案咨詢(xún)
二維碼
TOP