CodeIgniter Warning: Cannot modify header information please help

Source: Internet
Author: User
Tags php error codeigniter
CodeIgniter Warning: Cannot modify header information please master Help
I entered this code inside the controller.


Class Myfile1 extends Ci_controller
{
function Myfile1 ()
{
$str =file_get_contents ('./aa.txt ');
$str = $str? $str: 0;
$str + +;
File_put_contents ('./aa.txt ', $str);
$str =file_get_contents ('./aa.txt ');
Echo $str;



Then the result can be output $str correctly, but the output $str is then displayed.

A PHP Error was encountered

Severity:warning

Message:cannot Modify header Information-headers already sent by (output started at E:\AppServ\www\ci\application\contr OLLERS\MYFILE1.PHP:12)

filename:core/common.php

Line number:442


404 Page Not Found

The page you requested is not found.


Do not know what reason please expert guidance!!!


------Solution--------------------
PHP is recommended to install a xdebug, you can output an error of all tracking information, and then you know how this header output is called.
------Solution--------------------
The program has already told you the problem.
Headers already sent by (output started at e:\appserv\www\ci\application\controllers\myfile1.php:12)
It means that there is a situation in E:\AppServ\www\ci\application\controllers\myfile1.php 12th. there is content output before the header
Because there is absolutely no content output before the header, there is your current situation. Look at your code, where there's something wrong with the echo;print and stuff that goes out.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.