问题
Cannot send headers; headers already sent in /home/zk/public_html/lib/Zend/Cache/Backend/File.php, line 1
Trace:
#0 /home/zk/public_html/lib/Zend/Controller/Response/Abstract.php(115): Zend_Controller_Response_Abstract->canSendHeaders(true)
#1 /home/zk/public_html/app/code/core/Mage/Core/Model/App.php(1246): Zend_Controller_Response_Abstract->setHeader('Content-Type', 'text/html; char...')
#2 /home/zk/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(80): Mage_Core_Model_App->getResponse()
#3 /home/zk/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(202): Mage_Core_Controller_Varien_Front->getResponse()
#4 /home/zk/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#5 /home/zk/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#6 /home/zk/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#7 /home/zk/public_html/index.php(87): Mage::run('', 'store')
#8 {main}
I am new to magento and can't find the error
回答1:
This post will help you How to fix "Headers already sent" error in PHP
you can try putting in the start of the php file
<?php ob_start(); ?>
and in the end
<?php ob_end_flush(); ?>
回答2:
This error means that there was some output already sent, when Magento tried to send its headers. If you send output, headers are automatically sent just before that output and it's not possible to send another headers from that moment.
So try to check, if there is something sent to the output somewhere before the header function call. For example any character before the PHP opening tag <?php
causes sending of the output. It's also possible that character(s) is not visible, for example UTF-8 BOM (Byte Order Mark), so check it with hex-viewer/editor.
Also any character after the PHP close tag ?>
would cause that, so it's a good practice to omit PHP closing tags completely.
First of all, I would recommend to check what's in the file /home/zk/public_html/lib/Zend/Cache/Backend/File.php
on line 1. If there is just <?php
, check with hex-viewer if character "<" is the first in a file, or there are some invisible characters just before it.
来源:https://stackoverflow.com/questions/25105430/cannot-send-headers-headers-already-sent-in-home-zk-public-html-lib-zend-cache