CodeIgniter warning: Cannotmodifyheaderinformation should be handled by experts

Source: Internet
Author: User
Tags codeigniter
CodeIgniter warning: Cannotmodifyheaderinformation Please help you enter this code in the controller & nbsp; class & nbsp; Myfile1 & nbsp; extends & nbsp; CI_Controller & n CodeIgniter warning: cannot modify header information
Enter this code in 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 running result can be correctly output $ str, but $ str is output and 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 \ controllers \ myfile1.php: 12)

Filename: core/Common. php

Line Number: 442


404 Page Not Found

The page you requested was not found.


I don't know why. please give me some advice !!!

------ Solution --------------------
We recommend that you install xdebug for php to output all tracing information for an error, and then you will know how the 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 indicates that an error occurred 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, so your current situation occurs. look at your own code, where there should be echo; print and other things output content.

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.