1. 程式人生 > >php 解決Warning: Cannot modify header information

php 解決Warning: Cannot modify header information

環境:mac

問題:瀏覽器出現 Warning: Cannot modify header information - headers already sent by...

問題原因:函式 header(),setcookie() 和 session 函式需要在輸出流中增加頭資訊。但是頭資訊只能在其它任何輸出內容之前傳送。在使用這些函式前不能有任何(如 HTML)的輸出。函式 headers_sent() 能夠檢查您的指令碼是否已經發送了頭資訊。請參閱“輸出控制函式”。 意思是:不要在使用上面的函式前有任何文字,空行,回車,空格等。

解決方案:修改php.ini 檔案中 output_buffering 設為 on,然後重啟 appache;

具體步驟:終端命令

1、進入目錄:cd /etc/

2、複製檔案:cp php.ini.default php.ini

3、編輯修改檔案:sudo vi php.ini 

4、輸入 i 執行編輯,輸入output_buffering=on

5、esc 退出編輯

6、輸入 :wq 儲存退出

7、重啟伺服器 sudo apachectl restart

8、重新重新整理php檔案頁面。問題解決!

相關推薦

php 解決Warning: Cannot modify header information

環境:mac問題:瀏覽器出現 Warning: Cannot modify header information - headers already sent by...問題原因:函式 header()

解決Warning: Cannot modify header information

資訊的時候經常提示:cannot modify header information - headers already sent by (......)。其實已經實現需要的效果了,就是這個錯誤資訊看著不爽,網上找了很多辦法,綜合使用得到的解決方法是 1在頁面頂部的php標籤

Warning: Cannot modify header information解決辦法

昨天將本站的wordpress升級到最新版本,今天早上,經過兩位朋友的提醒,才發現用非chrome瀏覽器開啟部落格,頭部會顯示有錯誤,錯誤內容為: Warning: Cannot modify header information – headers already sent by (output

PHP錯誤:Warning: Cannot modify header information

如果在執行php程式時看到這條警告:"Warning: Cannot modify header information - headers already sent by ...." Few notes based on the following user posts:有

php5.6,Ajax報錯,Warning: Cannot modify header information - headers already sent in Unknown on line 0

ont line span use -s nbsp ati bsp data php5.6ajax報錯 Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be r

ajax 上傳檔案 報錯 Warning: Cannot modify header information - headers already sent in Unknown on line 0

在使用ajax更新或上傳資料的時候,return回來的卻是一堆錯誤 後來才知道原來是PHP5.6有的功能已經廢棄了,所以我需要開啟PHP.ini檔案,找到 ;always_populate_raw_post_data = -1 將前面的分號去掉 always_popula

PHP提示Cannot modify header information - headers already sent by解決方法

PHP提示Cannot modify header information - headers already sent by解決方法 因為 header();傳送頭之前不能有任何輸出,空格也不行, 需要將header()之前的空格去掉,或者其他輸出的東西去掉, 如果他上面include其他檔案了,你還

PHP經典header錯誤"Cannot modify header information"的解決方法(轉)

錯誤提 示:Cannot modify header information - headers already sent by .... 昨晚在轉換編碼的時候,有一個 頁面需要在head中申明utf-8的編碼,但是這與程式中的一處header產生了衝突。google了一下,找到幾種解決方法,翻譯整

php-fpm: 某項目網站頻繁出現503問題解決( WARNING: [pool www] server reached pm.max_children setting (50), consider raising it)

www. 監控 arp https php-fpm配置 找到 class conf nbsp 服務是nginx+php-fpm配置, 在運行過一段時間後,會經常出現: WARNING: [pool www] server reached pm.max_children

php 出現Warning A non numeric value encountered問題的原因及解決方法

                     本文介紹php出現Warning: A non-numeric value encountered問題,用例項分析出現這種錯誤的原因,並提供避免及解決問題的方法。 <?phperror_reporting(E_ALL);ini_set('display_erro

Ubuntu gedit報錯Gtk-WARNING **: cannot open display: :0.0 解決辦法

當使用su 到另外一個使用者執行某個程式,而這個程式又要有圖形顯示的時候,就有可能有下面提示: No protocol specified (gedit:2144): Gtk-WARNING **: cannot open display: :0 解決辦法:這是因為Xserver預設情況

輕鬆解決遠端連結的“Gtk-WARNING **: cannot open display;”或“Cannot connect to display;”問題

遠端連線伺服器或者工作站的時候,通常不能開啟一個GUI圖形使用者,而且在開啟過程中會出現諸如:(gedit:46927): Gtk-WARNING **: cannot open display:或者:指令名:Cannot connect to display的提示。那麼如何

Gtk-WARNING **: cannot open display問題的解決

1. SDL安裝 2. ssh連線配置,x11forwarding 與VNC方式不同,qemu-kvm利用圖形介面方式開啟虛擬機器,會以彈出視窗的方式與虛擬機器互動。某些情況下,工作環境是通過各種term程式利用ssh登入到伺服器,這時執行qemu的啟動程式,通常會

php解決json_encode輸出GB2312中文問題 (數組)

傳遞 urn ble $apply googl 對數 unset light return 在 php 中使用 json_encode() 內置函數(php > 5.2)可以使用得 php 中數據可以與其它語言很好的傳遞並且使用它。 這個函數的功能是將數值轉換成jso

mysql大數據分庫和分表 php解決方案!

表結構 處理方式 很好 fig struct 提升性能 this 區別 turn 當Mysql數據量過大時,就會面臨壓力分解,這時分庫分表是一個不錯的解決方案,現在我們就來談談Mysql如何分庫分表比較理想,然後再用php如何調用。 1,主從復制,讀寫分離對主

源碼安裝zabbix3.2.7時PHP ldap Warning

進行 hose work following 系統 .com system copy modules 問題如下: 解決方法: 1、首先查看源碼安裝的php模塊中是否有ldap.so [[email protected]/* */ ldap]# ll /us

php 解決json_encode中文UNICODE轉碼問題

*** www. str .com 再次 alt pan 進行 可讀的 原文地址:php 解決json_encode中文UNICODE轉碼問題用PHP的json_encode來處理中文的時候, 中文都會被編碼, 變成不可讀的, 類似"\u***"的格式,如果想漢字不進行轉碼

PHP報錯Cannot adopt OID in UCD-SNMP-MIB、 LM-SENSORS-MIB

fig agg ror 怎麽辦 all output agent org temp Cannot adopt OID in UCD-SNMP-MIB: Cannot adopt OID in LM-SENSORS-MIB: lmTempSensorsValue 運行PHP遇

PHP解決網站大數據大流量與高並發

支持 們的 emca 網通 開啟 不用 分類 跨站 連接 1:硬件方面 普通的一個p4的服務器每天最多能支持大約10萬左右的IP,如果訪問量超過10W那麽需要專用的服務器才能解決,如果硬件不給力 軟件怎麽優化都是於事無補的。主要影響服務器的速度 有:網絡-硬盤讀寫速度-內存

phpize建立php擴展 Cannot find config.m4

一個 php擴展 pro per -m dir ron its level phpize建立php擴展Cannot find config.m4[[email protected] root]# phpize  Cannot find config.m4.  M