我刚开始学习 PHP,所以我安装了最新版本 (5.3.3) 并正在编写一些代码。我遇到过这个错误:
PHP Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in C:\Rush\dev\personal\Numina.Framework\Development\PHP Library\Numina.Framework\clsHttpUtil.php on line 47
当我查找 safe_mode 的文档时,它告诉我它已被弃用。为什么它被弃用了,我该怎么做才能解决这个错误?
最佳答案
safe_mode
的初衷是好的,但实现起来参差不齐。它已被弃用,因为它引起的问题多于解决的问题,并且不是通用的安全解决方案。现在有更好的方法来实现应用程序的环境保护(如FastCGI、suexec、chroots、jails、VPSes...)
您可以通过关闭 safe_mode
来修复您的错误,并且设计您的代码时不要假设它正在被使用或被废弃。 请注意,自 PHP 5.4.0 起,safe_mode
已被删除。
这是 more information on why CURLOPT_FOLLOWLOCATION
was disabled当 safe_mode
或 open_basedir
生效时。像这样的问题是 safe_mode
可能会完全从 PHP 中删除的主要原因之一。
关于安全模式的 php 替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3349280/