Jump to content

header function working after HTML output; can anyone explain why?


pliant

Recommended Posts

I was asked to make a page that would register with Opentracker before redirecting to the main page of our site.  I put this script up on one of our servers running php 5.1.6, and to my very great surprise, it worked:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

        <head>

                <title>Tracking Title</title>

        </head>

        <body>

                <!-- OPENTRACKER HTML START -->

                <script defer src="http://server1.opentracker.net/?site=www.thesite.com"></script>

                <noscript><a href="http://www.opentracker.net" target="_blank"><img src="http://img.opentracker.net/" alt="page counter" border="0"></a></noscript>

                <!-- OPENTRACKER HTML END -->

        </body>

</html>

<?php header('location: http://www.thesite.com') ;?>

 

It also works on another server running the same version of php.  On an alternate server, still running 4.3.11, it gave the expected 'headers already sent' error. 

 

Can anyone explain to me why does this script works on two of my servers?  I looked through the header() manual page and was unable to find any php5 updates that would account for this.

 

Thanks for reading.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.