Jump to content

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


floridaflatlander

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.