Should I be using mysql_close() at the end of all my scripts? I've been told that using non-persitant connections will result in the connection closing once the script is finished. Thoughts?
php will close the connection to the mysql database after the script has concluded. there is (usually) no need to use mysql_close() in a typical web-application.
The PHP online manual entry for mysql_close() reads in part:
Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution. See also freeing resources.
Due to the reference-counting system introduced with PHP 4's Zend Engine, it is automatically detected when a resource is no longer referred to (just like Java). When this is the case, all resources that were in use for this resource are made free by the garbage collector. For this reason, it is rarely ever necessary to free the memory manually by using some free_result function.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.