Oops! I just noticed a case error in my script:
Header("Location:friendlyerrorpage.php");
should be:
header("Location:friendlyerrorpage.php");
However, the problem is still there - on my dev server anyway. I tried the script on another server (IIS5 / PHP 4.3.4) and I don't get the header already sent error so it seems to be something to do with the PHP or web server configuration that is causing the header to be sent?
On the second server I do get:
Fatal error: Maximum execution time of 1 second exceeded in E:\Public\wwwroot\Customer\MaxExecTest.php on line 17
Fatal error: Maximum execution time of 1 second exceeded in E:\Public\wwwroot\Customer\MaxExecTest.php on line 5
Lines 5 and 17 are:
if (connection_status()!=0){
and
echo "Something useful would normally go here.";
respectively.
So the shutdown function is not working. It seems the echo line is getting parsed even though the function toolong is getting called? This doesn't make sense to me. I thought that was what the register_shutdown_function() was supposed to be for - to intervene in such cases.
If I comment out the echo line, the max exec error occurs at the next line and if I comment it out, the max exec occurs at the last line (the closing tag).