Jump to content

Does exit() remove a query's overhead & close a database connection?


Recommended Posts

I've been wrting this are the bottom of a script

 

header("Location: $home/index.php");
mysqli_free_result($r);
mysqli_close($dbc);
exit(); 

 

I was wondering can exit() remove a querys overhead and close a database connection also, meaning this is the same thing.

 

header("Location: $home/index.php");
exit(); 

 

php.net says exit() "Terminates execution of the script". So maybe it closes the db connection(a script) but leaves a query's overhead??

 

There is absolutely no need to ever use the free_result () or close () methods/functions on SQL connections, simply because PHP handles all of this automatically when the script ends. This happens both on normal execution end (getting to the end of the file) and when you kill off the script early (via die ()).

This has nothing to do with the functions you use, but is a standard part of the PHP interpreter's clean up routines.

 

So no overhead left, at all.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.