Tags
PHP , Lamp
Asked 7 years ago
17 Nov 2016
Views 1114
joomler

joomler posted

PHP Warning: Cannot modify header - headers already sent - Error in php ?

i found this WARNING in php script
PHP Warning: Cannot modify header information - headers already sent by (output started at home.php:2) in func.php on line 46

how can i solve this ?
ravi

ravi
answered Nov 30 '-1 00:00

header sent come in php when output already sent by php any how before header redirection happen or header sending process start by header function

so you need to remove function which already sending output before header function run.

so go to func.php at line 46 check whether any code is sending output like echo or print any of it

if yes you need to remove it or store it buffer until all program run and view start .

Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

some of the good tip to avoid " Header sent php Error " in php

1. buffer output all until view part (HTML) start.
use ob_start() which used for buffering output. and ob_end_clean() which clean all output done by script so wrap all code by this two function.

2. try to understand the header should be sent first so avoid programming style where view part come first and logic come later.

3. make a common file where header redirection come at first and include at script first

Post Answer