可以“magic_quotes_gpc”吗?在 PHP 5.3 中启用吗?
在 PHP 5.3 中,可以启用“magic_quotes_gpc”吗?
据我所知,它在 PHP 5.3 中已被弃用,但我正在安装的 PHP 脚本需要它,否则它将无法工作。
In PHP 5.3, can "magic_quotes_gpc" be enabled?
I understand that it is deprecated in PHP 5.3, but a PHP script I am installing requires this otherwise it won't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它必须在 .ini 级别完成。它不能在脚本中使用 ini_set() 完成,因为在处理 ini_set() 时,PHP 已经完成启动并且各种超全局数组(POST/GET/REQUEST/等...)已被设置并且不会改变。
您可以使用 Apache
指令启用每个脚本的设置,因为为所有 PHP 脚本启用魔术引号是一个可怕的想法:It has to be done at the .ini level. It can't be done within a script using ini_set(), because by the time the ini_set() is processed, PHP has already completed startup and the various superglobal arrays (POST/GET/REQUEST/etc...) have been set and will NOT be changed.
You can enable the setting per-script using an Apache
<Files>
directive, since enabling magic quotes for all PHP scripts is a horrible idea:然后不要使用该脚本启用魔术引号是非常糟糕的。
DOC
为什么不在 DOC 中
Then do not use that script it is quite bad to have magic quotes enabled.
DOC
WHY-NOT in DOC
您可以使用简短的脚本模拟 magic_quotes,例如:
请注意,您需要一个 递归变体实际上。当您使用它时,您至少可以使用
_real_escape_string
而不是addslashes
(这实际上仅在您的数据库和连接仅使用 ASCII 时才允许)。要为所有脚本启用此功能,请使用 php.ini 选项:
至少在 PHP 5.3 中,仍然可以启用此过时的功能。
You can simulate magic_quotes with a short script like:
Note that you need a recursive variant actually. And while you're at it you could at least use
_real_escape_string
rather thanaddslashes
(which is really only allowable if your database and connection uses ASCII only).To have that enabled for all scripts use the php.ini option:
At least in PHP 5.3 it's possible to still enable this outdated feature however.
是的,可以。该功能默认处于禁用状态,但尚未删除。只需修改您的 php.ini 文件(或使用 Marc B 的建议仅针对特定脚本启用它)
Yes it can. The feature is disabled by default, but has not been removed. Just modify your php.ini file (or use Marc B's suggestion to enable it for specific script only)