note 91521 added to function.register-shutdown-function

From: Date: Mon, 15 Jun 2009 02:49:51 +0000
Subject: note 91521 added to function.register-shutdown-function
Groups: php.notes 
Request: Send a blank email to php-notes+get-156864@lists.php.net to get a copy of this message
There is a mibehavior on different configurations of php, when you call exit (outside of registered function), the registered function will / or will not be executed. There are some code examples in comments on this page, showing that after exit (outside of registered func) registered functions are called, but I've made some tests and it doesn't work on Windows with Apache2 and php5 installed as module. I've submitted a bug about this, and jani @ php developer answered me with this: "Expected behaviour. exit() is supposed to exit immediately. Nothing is supposed to be run after you call exit." (http://bugs.php.net/bug.php?id=48475) Here is the code example, and tests on a few different configurations: <?php function shutdown() { file_put_contents(dirname(__FILE__).'/shutdown.txt', time()); } register_shutdown_function('shutdown'); exit(); ?> Win+Apache+php5 as mod - shutdown.txt IS NOT created. Win+Apache+php5 as cgi - shutdown.txt IS created Win+Apache+php4 as mod - shutdown.txt IS created Win+Lighttpd+php5 as fcgi - shutdown.txt IS created Linux+Apache+php4 as mod - shutdown.txt IS created Linux+Lighttpd+php5 as fcgi - shutdown.txt IS created -------- Seems like there is an unexpected behavior on most platforms. Only Win+Apache+php5 as mod behaves correctly. That is what jani@php.net states. ---- Server IP: 92.48.74.199 Probable Submitter: 83.31.217.187 ---- Manual Page -- http://www.php.net/manual/en/function.register-shutdown-function.php Edit -- https://master.php.net/note/edit/91521 Del: integrated -- https://master.php.net/note/delete/91521/integrated Del: useless -- https://master.php.net/note/delete/91521/useless Del: bad code -- https://master.php.net/note/delete/91521/bad+code Del: spam -- https://master.php.net/note/delete/91521/spam Del: non-english -- https://master.php.net/note/delete/91521/non-english Del: in docs -- https://master.php.net/note/delete/91521/in+docs Del: other reasons-- https://master.php.net/note/delete/91521 Reject -- https://master.php.net/note/reject/91521 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#156864) next »