0

我正在使用表单从用户那里提取 iframe 代码并将其插入另一个页面。但是,当代码被拉入时,它会在混合中插入一个“\”。

这是原始代码:

<iframe src='http://listings.realbird.com/home-search-o/?rb_id=N7T5O2I2&bq=[item type:housing][location:@%22Reno, Nv%22][listing type:housing/sale][property type:/foreclosure]&orderby=price' frameborder='0' width='100%' height='2700' style='width:100%; height:2700px;'></iframe>

这是php文件处理后的代码:

<iframe src=\'http://listings.realbird.com/home-search-o/?rb_id=N7T5O2I2&bq=[item type:housing][location:@%22Reno, Nv%22][listing type:housing/sale][property type:/foreclosure]&orderby=price\' frameborder=\'0\' width=\'100%\' height=\'2700\' style=\'width:100%; height:2700px;\'></iframe>

有什么办法可以防止这种情况发生?

4

2 回答 2

1

这对我来说就像魔术引号。您可以尝试将 ' 的所有实例替换为 '

或查看 PHP 方法stripslashes

于 2013-08-28T22:46:46.483 回答
0

看看这里: http ://www.dreamincode.net/forums/topic/147880-does-php-5-automatically-addslashes/

一些 PHP 默认配置会自动在表单上提交的内容上添加斜杠,这样如果您想将其插入数据库或类似的东西,使用它会“更安全”。

如果你想防止这种行为,我认为你可以通过使用类似的东西为你的整个 php 应用程序关闭它: set_magic_quotes_runtime(false);

http://www.php.net/manual/en/function.set-magic-quotes-runtime.php

试试看。

于 2013-08-28T22:51:47.257 回答