第1个回答 推荐于2016-12-04
用register_shutdown_function函数就行了。下面是例子。
<?php
function shutdown($user)
{
// This is our shutdown function, in
// here we can do any last operations
// before the script is complete.
// echo 'Script executed with success', PHP_EOL;
file_put_contents('d:/a.php',$user."已离线\n",8); //写入到d盘a.php文件中,追加方式。
}
register_shutdown_function('shutdown','abc'); //每个脚本加入这句就行了。
sleep(10); //这是本地测试用的,方便你关闭网页。
?>本回答被提问者和网友采纳