|
Do you have a favorite 'exit'? Why?
|
|
02-25-2012, 04:41 AM
Post: #1
|
|||
|
|||
|
Do you have a favorite 'exit'? Why?
PHP Code: <?phpIs there any difference between these two 'exit;' vs. 'exit();' I'm guessing no difference, but curious to know... Why would anyone bother to use 'exit();' if 'exit;' does the same thing? ![]() Do you have a favorite 'exit'? Why? # MyBB is the best forum software!
|
|||
|
02-25-2012, 05:09 AM
Post: #2
|
|||
|
|||
|
RE: Do you have a favorite 'exit'? Why?
exit is a language construct. It makes no difference if you use exit or exit() it just depends on the developer.
Personally I use exit but other developers might like to be consistent and use exit() along side exit('Some message'). exit is also an alias of die (I tend to use die when outputting error messages and use exit when I want the script to generally exit) Nathan Malcolm MyBB Development Team Your question has already been answered. MyBB Security |
|||
|
02-25-2012, 07:42 AM
Post: #3
|
|||
|
|||
|
RE: Do you have a favorite 'exit'? Why?
I usually just use die() but sometimes exit;
Quote:Golf and alcohol don't mix, that's why I don't drink and drive!Video Tutorials: Installing MyBB | Upgrading MyBB |
|||
|
02-25-2012, 05:14 PM
(This post was last modified: 02-25-2012 05:15 PM by TheGarfield.)
Post: #4
|
|||
|
|||
|
RE: Do you have a favorite 'exit'? Why?
I prefer "exit;"
Though, you shouldn't rely too much on that, it's better to do : PHP Code: <?phpThen : PHP Code: <?phpSorry seems to be the hardest word! |
|||
|
02-26-2012, 01:59 AM
Post: #5
|
|||
|
|||
|
RE: Do you have a favorite 'exit'? Why?
Personally, unless there's some kind of exceptional situation, I just let execution run off the end and return normally. Of course, almost all of the PHP I've written was for MyBB so exit() would mess things up, but even in normal C/C++ programs I just return from main to end the program.
|
|||
|
02-26-2012, 02:12 AM
Post: #6
|
|||
|
|||
|
RE: Do you have a favorite 'exit'? Why?
I use exit(), which is for consistency as Nathan stated. I use exit(); for exiting and die("Some Message"); for error messaging... but I often use:
echo "<pre>";print_r($array_var);die("</pre>"); for debugging insertions too
CodeWeavers - CrossOver: Windows Compatibility on Macintosh and Linux ![]() Doesn't like unsolicited PMs |
|||
|
02-26-2012, 02:40 AM
Post: #7
|
|||
|
|||
|
RE: Do you have a favorite 'exit'? Why?
I use exit(); myself...not sure why I just always preferred that to just exit;.
I do of course use die() too but in terms of just exit options I like exit();. /My Plugins/ |
|||
|
02-29-2012, 11:51 AM
(This post was last modified: 02-29-2012 12:01 PM by seeker.)
Post: #8
|
|||
|
|||
|
RE: Do you have a favorite 'exit'? Why?
BTW, Would..
//exit with an error code (for example) exit(123); ...by default, log the error in the Apache logs (assuming you normally see PHP errors there) or do you need to add the instruction to log? EDIT: Checked here and didn't see much use of the error code. <off topic> Quote:Don't use the exit() function in the auto prepend file with fastcgi (linux/bsd os).</off topic> EDIT #2 Just tested and don't see it in the Apache log. How do you ever use that error code?, since the script has stopped...
# MyBB is the best forum software!
|
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)
Search
Member List
Calendar
Help







![[Image: Advocate_125.png]](http://media.codeweavers.com/pub/crossover/marketing/link_banners/Advocate_125.png)