register_shutdown_function
register_shutdown_function
- used to register functions which will be called after script reaches end.
- we can register multiple functions using register_shutdown_function
Arguments:
- func (which takes function name)
Example:
function myFunction(){
echo “My Fucntion”;
}
register_shutdown_function(myFunction);
echo “My Script”;
Usage:
Basically, it is used for clean up purpose.
For example, to close the file handles, close database connections,close sessions and etc.
Note : don’t give exit() in any registered function. if you give exit in a function, other register functions won’t be called.
