Headers already sent – Solve

1 min


0
1 share

Warning - Headers already sent
Warning - Headers already sent

Most programmers get the warning of headers already sent in php. This warning occurs due to using header function of php. To remove the warning in your webpage simply place @ in front of header function but this stops working of header function some time. To solve this problem you can use javascript redirect function. Here is the code:-

<?php
echo "<script type='text/javascript'>
<!--
window.location = 'http://www.msn.com/'
//-->
</script>";
?>



Like it? Share with your friends!

0
1 share

What's Your Reaction?

LIKE LIKE
0
LIKE
DISLIKE DISLIKE
0
DISLIKE
DAMN DAMN
0
DAMN
CUTE CUTE
0
CUTE
OMG OMG
0
OMG
Junaid Rehman

I am a blogger and freelance web developer by profession. I love to blog and learn new things about programming and IT World.

One Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

  1. Hi its not because of header function. the Headers already sent occurs when you have html output before the call of header function and also putting the @ symbol will silent the error in all cases but won’t let the header function work.
    So this code is better
    <?php
    echo "location.href=’page.php’;”;
    Get me on
    http://kaysellers.com
    ?>