www.webdeveloper.com
Results 1 to 5 of 5

Thread: exit();

  1. #1
    Join Date
    Dec 2005
    Posts
    492

    exit();

    My logic tells me that using "exit();" at the end of my php output speeds up the page load process.

    My site is based around one php file which outputs html depending on the url string. So, after any of the code prints my $standardfooter ... aka echo ('</table></body></html>'); ... by putting exit(); on the next line, I'm saying "don't worry about the rest, just deliver the goods that were requested."

    Am I wrong?

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,337
    It may save you a few milliseconds, but it's not impossible that a script could have necessary actions after the end of the HTML is output (such as database inserts or updates).

    In fact, since your script gets compiled at run-time by the PHP parser, it may well optimize out any code branches that won't get executed, so you may not really save any time, anyway, in some situations.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Dec 2005
    Posts
    492
    My site is just a simple musician site with html content ... but your response has me wondering if I should avoid using it?

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,337
    Personally, I doubt the potential processing time savings are worth the bother, unless you are expecting hundreds of hits per minute, in which case it might be worth doing some code execution profiling and testing to see if it actually has any measurable impact.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Dec 2005
    Posts
    492
    advice taken. thanks man.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles