Page 1 of 1
mysqli_close() needed?
Posted: Sat Sep 01, 2007 7:13 am
by WaldoMonster
After connecting to a database with mysqli_connect() is mysqli_close() needed or will it be automatically closed on the end of a script?
Posted: Sat Sep 01, 2007 7:14 am
by volka
The resource will be collected when it becomes unreachable by the script (that includes the end of the script). The connection will be closed then.
Posted: Sat Sep 01, 2007 9:21 am
by feyd
Although closing it yourself can free up resources earlier allowing other operations to start earlier.
Posted: Sat Sep 01, 2007 10:11 am
by WaldoMonster
This means that something like this makes no sense:
Code: Select all
if (isset($db)) mysqli_close($db);
exit();
Posted: Sat Sep 01, 2007 10:15 am
by volka
But it doesn't hurt either.