PHP和MySQLi close() [英] PHP and MySQLi close()

查看:68
本文介绍了PHP和MySQLi close()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MySQL和PHP的新手,并且正在尝试制作自己的CMS,以帮助简化网站管理.有人可以解释mysqli的close()函数吗?

I am new to MySQL and PHP and am attempting to make my own CMS to help make managing my websites easier. Can someone explain mysqli's close() function?

  1. 有必要吗?
  2. 它到底是做什么的?
  3. 我听说PHP运行脚本后,它将关闭 联系,是真的吗?
  4. 最后,不关闭连接时是否存在安全问题 到数据库?
  1. Is it necessary?
  2. What exactly does it do?
  3. I heard that after PHP runs its script that it closes the connection, is that true?
  4. Lastly, is there a security issue when not closing your connection to the database?

推荐答案

有必要吗?

Is it necessary?

否,PHP将在完成运行后终止您的连接.

No, PHP will end your connection after it finishes running.

它到底是做什么的?

What exactly does it do?

mysqli_connect()的相反部分-关闭活动的数据库连接.

The reverse of mysqli_connect() -- it closes the active DB connection.

我听说PHP运行脚本后,它会关闭连接,这是真的吗?

I heard that after PHP runs its script that it closes the connection, is that true?

是的,请参阅是否有必要?"的答案

Yes, see the answer to "Is it necessary?"

最后,当不关闭与数据库的连接时是否存在安全问题?

Lastly, is there a security issue when not closing your connection to the database?

不,没有安全问题.连接不能被外部人或类似的东西劫持.

Nope, no security issue. The connection can't be hijacked by an outsider or anything like that.

但是,由于可用的总连接数是有限的,因此在完成处理后的第二秒释放资源被认为是礼貌的做法,以便在完成处理后将其关闭.这可能就是为什么您被告知在完成后将其关闭的原因.

However, since the number of total connections available is limited, freeing the resource the second you're done with it is considered polite to close it when you're done. This is likely why you've been told to close it when you're done.

这篇关于PHP和MySQLi close()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆