header() function to send an HTTP
Contrary to what some think,
die() has nothing to do with redirection. Use it only if you want to redirect instead of normal execution.
<?php header('Location: static.html'); $fh = fopen('/tmp/track.txt', 'a'); fwrite($fh, $_SERVER['REMOTE_ADDR'] . ' ' . date('c') . "\n"); fclose($fh); ?>
Result of three executions:
[email protected]:~> cat /tmp/track.txt 127.0.0.1 2009-04-21T09:50:02+02:00 127.0.0.1 2009-04-21T09:50:05+02:00 127.0.0.1 2009-04-21T09:50:08+02:00
Resuming — obligatory
exit() is some urban legend that has nothing to do with actual PHP. It has nothing to do with client “respecting” the
Location: header. Sending a header does not stop PHP execution, regardless of the client used.