Cynosure.X International LLC

:

Add Comment | Related Links | TrackBack
Related Content

Quick Way to Circumvent "exit" Call

Recently I came across some PHP codes where the developer(s) of the code littered "exit" all through out, where errors/exceptions/failures occur. (This technique seems to be the trend for many MySQL/PHP software as well.) That technique made the code difficult to extend and embed into other functionality, because PHP execution would stop immediately upon encountering the "exit" call.

The best solution is to re-architecture the execution flow with structured programming and eliminating all "exit" calls. However, that will be an expensive expenditure for this pre-existing software. Luckily with PHP 5.3, there is an easy way out.

The easy way is to use the "goto" statement with a label. (Yes. I know "goto" is a taboo against structured programming. And for once in my life, I am grateful that it is a part of PHP 5.3 and later.) By placing a "end:" label at the end of the source code execution (each source file), a simple search-and-replace of "exit;" with "goto end;" did the trick.

Chieh Cheng
Wed, 30 Mar 2011 22:41:31 +0000

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Add Comment

Spam Control | * indicates required field
Your Name: *
E-mail:
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 5 + 4?
Click button only once, please!

TrackBack

TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.

Send Ping | TrackBack URL | Spam Control

No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.

Messages, files, and images copyright by respective owners.

Products | Services
Forums | Latest | RSS
Library | Search | Wiki
Help | Licenses

Login | Register

104 Users Online

Hacking Digital Cameras
Fun for Photographers


Get Our

Memecoins!



Amazon Associate

Copyright © 1996 - 2024. All Rights Reserved.