CodeIgniter warning: Cannotmodifyheaderinformation Please help you enter this code & nbsp; classMyfile1extendsCI_Controller & nbsp ;{& nbsp; functionmyfile1 () & nbsp ;{& nbsp; 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.