PHP file() 在单引号中添加斜杠

发布于 2024-09-28 02:14:16 字数 254 浏览 4 评论 0原文

我有一个运行 5.3.3 的 PHP 安装,当我使用下面的代码时:

    $sql = file('sql.txt');
    var_dump($sql);

我的所有单引号都被转义。为什么会出现这样的情况。服务器上启用了魔术引号(由于某种原因,它超出了我的控制范围),但是我认为魔术引号仅适用于 GET POST COOKIE 和 REQUEST?我在最新的 PHP 中还缺少其他东西吗?

有什么想法吗?

I have a PHP installation running 5.3.3 and when I use the code below:

    $sql = file('sql.txt');
    var_dump($sql);

All my single quotes are escaped. Why would this be happening. Magic quotes is enabled on the server (for some reason, it is out of my control) however I thought that magic quotes was only applied to GET POST COOKIE and REQUEST? I there something else I am missing here with the latest PHP?

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千纸鹤带着心事 2024-10-05 02:14:16

magic_quotes_runtime 导致此情况。值得庆幸的是,这个“功能”默认是关闭的,但显然它在你的服务器上启用了。

magic_quotes_runtime causes this. Thankfully, this "feature" is off by default, but apparently it's enabled on your server.

○闲身 2024-10-05 02:14:16

来自 php.net:

如果 magic_quotes_runtime 启用,
大多数函数返回数据
任何类型的外部来源,包括
数据库和文本文件将有
引号用反斜杠转义。

From php.net:

If magic_quotes_runtime is enabled,
most functions that return data from
any sort of external source including
databases and text files will have
quotes escaped with a backslash.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文