note 13850 added to function.register-shutdown-function.php
| From: | ikoster at exed dot nl | Date: | Fri, 06 Jul 2001 03:55:54 +0000 |
| Subject: | note 13850 added to function.register-shutdown-function.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15026@lists.php.net to get a copy of this message | ||
I had a register_shutdown_function for making a log for the pages that ends. In the log file a want
the i.p., but it don't work like i did.
Exemple:
register_shutdown_function("shutdown");
function shutdown()
{
$ip = getenv("REMOTE_ADDR");
$query = "insert into log values('','$ip','otherinfo')";
mysql_query($query);
}
But that don't work, if your script is shutdown't you don't have a env anymore. So
thats why getenv won't work.
You can solfe it like this:
$ip = getenv("REMOTE_ADDR");
register_shutdown_function("shutdown");
function shutdown()
{
global $ip;
$query = "insert into log values('','$ip','otherinfo')";
mysql_query($query);
}
http://php.planetmirror.com/manual/en/function.register-shutdown-function.php