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 - Manual: mysqli::close
2024-11-14
(PHP 5, PHP 7, PHP 8)
mysqli::close -- mysqli_close — 关闭先前打开的数据库连接
成功时返回 true
, 或者在失败时返回 false
。
See mysqli_connect().
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.