Register_shutdown_function usage: register_shutdown_function usage
/*** Created by PhpStorm. * User: echo * Date: 2016/3/8 * Time: 20:26 */function errorLog () {ob_start (); // enable ob cache $ error = error_get_last (); // Obtain the error message if (in_array ($ error ['type'], array (E_ERROR, E_WARNING) {$ content = ob_get_contents (). json_encode ($ error ). PHP_EOL; // get the content file_put_contents ('. /error. log', $ content, FILE_APPEND); ob_end_clean () ;}}// when the script is running or an error occurs, the registered function errorLog // The current er In the rorLog function, you need to make a judgment: logs can be recorded only when an error occurs, otherwise it will not make much sense. Register_shutdown_function ("errorLog" comment @fopen('a.txt ','');
The above is the usage of the register_shutdown_function function. For more information, see The PHP Chinese website (www.php1.cn )!