note 100731 added to function.exit

From: Date: Wed, 03 Nov 2010 13:54:16 +0000
Subject: note 100731 added to function.exit
Groups: php.notes 
Request: Send a blank email to php-notes+get-173710@lists.php.net to get a copy of this message
If you want to avoid calling exit() in FastCGI as per the comments below, but really, positively want to exit cleanly from nested function call or include, consider doing it the Python way: define an exception named `SystemExit', throw it instead of calling exit() and catch it in index.php with an empty handler to finish script execution cleanly. <?php // file: index.php class SystemExit extends Exception {} try { /* code code */ } catch (SystemExit $e) { /* do nothing */ } // end of file: index.php // some deeply nested function or .php file if (SOME_EXIT_CONDITION) throw new SystemExit(); // instead of exit() ?> ---- Server IP: 195.114.0.19 Probable Submitter: 213.136.233.250 ---- Manual Page -- http://www.php.net/manual/en/function.exit.php Edit -- https://master.php.net/note/edit/100731 Del: integrated -- https://master.php.net/note/delete/100731/integrated Del: useless -- https://master.php.net/note/delete/100731/useless Del: bad code -- https://master.php.net/note/delete/100731/bad+code Del: spam -- https://master.php.net/note/delete/100731/spam Del: non-english -- https://master.php.net/note/delete/100731/non-english Del: in docs -- https://master.php.net/note/delete/100731/in+docs Del: other reasons-- https://master.php.net/note/delete/100731 Reject -- https://master.php.net/note/reject/100731 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173710) next »