gpt4 book ai didi

php - 为什么 mysqli_escape_string 需要数据库连接?

转载 作者:行者123 更新时间:2023-11-29 03:59:56 25 4
gpt4 key购买 nike

为什么我不能使用 mysqli_escape_string在没有数据库连接的情况下运行?

最佳答案

来自 the documentation :

Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection

它必须有一个连接,这样它才能知道数据库正在使用什么字符集,这样它才能使用正确的规则来转义数据。

关于php - 为什么 mysqli_escape_string 需要数据库连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37865117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com