Page 1 of 1

PHP Warning: Cannot modify header information - headers already sent by

Posted: Mon 14 Aug 2017 6:34 pm
by ConligWX
Ken,

thought I would bring this to your attension, though not sure if anyone else actually gets this error message themselves, I would guess most do not look at error logs on their webserver :)

Lately I have noticed many errors listed like so:

Code: Select all

[Mon Aug 14 12:10:34.811473 2017] [php7:warn] [pid 3401:tid 140485525542656] [client xx.xxx.xxx.xx:50973] PHP Warning:  Cannot modify header information - headers already sent by (output started at /share/xxxxxx/xxxxx/top.php:146) in /share/xxxxxx/xxxxx/htdocs/weather/header.php on line 34
I've tried searching to answer but most I do not understand.

one however showed the following..


Source: https://stackoverflow.com/questions/802 ... ror-in-php
Typical causes:

Print, echo

Intentional output from print and echo statements will terminate the opportunity to send HTTP headers. The application flow must be restructured to avoid that. Use functions and templating schemes. Ensure header() calls occur before messages are written out.

Functions that produce output include

print, echo, printf, vprintf
trigger_error, ob_flush, ob_end_flush, var_dump, print_r
readfile, passthru, flush, imagepng, imagejpeg

among others and user-defined functions.
the error I shows has on line 146: print $FlyoutCSS;

So is this could possibly an issue with my PHP 7.1.8 and Apache 2.4.27 setup perhaps?

I'm really just curious as on the website it appears everything is working fine.

Re: PHP Warning: Cannot modify header information - headers already sent by

Posted: Mon 14 Aug 2017 6:53 pm
by saratogaWX
Your header.php has a line

Code: Select all

header('Content-Type: text/html; charset=utf-8');
that is not in the distributed header.php .. that's what is causing the extra warning statement.

In the template, the character set is established by top.php with

Code: Select all

//Version  V3.04 - 05-Feb-2013 - added support for HTML5+UTF8
############################################################################
if(isset($useUTF8) and function_exists('set_langtrans_UTF8') ) {
	set_langtrans_UTF8(); // convert langrans items to UTF-8
}
header("Content-Type: text/html; charset=".strtoupper($SITE['charset']));
to support the multiple languages with different character sets.

Re: PHP Warning: Cannot modify header information - headers already sent by

Posted: Mon 14 Aug 2017 7:05 pm
by ConligWX
:groan:

Once again, Thanks! :clap: