I've had situations where database connections appeared to persist following php execution. So, now, my __destructor function explicitly contains a $cxn->close(). It hurts nothing, and helps avoid memory leaks.
(PHP 5, PHP 7)
mysqli::close -- mysqli_close — Closes a previously opened database connection
객체 기반 형식
절차식 형식
Closes a previously opened database connection.
Open non-persistent MySQL connections and result sets are automatically destroyed when a PHP script finishes its execution. So, while explicitly closing open connections and freeing result sets is optional, doing so is recommended. This will immediately return resources to PHP and MySQL, which can improve performance. For related information, see freeing resources
성공 시 TRUE
를, 실패 시 FALSE
를 반환합니다.
See mysqli_connect().
Note:
mysqli_close() will not close persistent connections. For additional details, see the manual page on persistent connections.
I've had situations where database connections appeared to persist following php execution. So, now, my __destructor function explicitly contains a $cxn->close(). It hurts nothing, and helps avoid memory leaks.