iframe在我的php代码中添加了src标签和高度宽度标签中的额外\

时间:2015-03-14 06:41:50

标签: iframe

当我在我的表单字段中添加iframe并且地图没有在localhost中显示它时,iframe自动添加了iframe,但在上传服务器之后添加了额外的斜杠,请帮助我。谢谢。

iframe代码

<iframe src=\"https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d3204.655372160928!2d-78.06299779999999!3d36.5624217!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89adfb01f721a0fb%3A0xd4727f928bfd3f27!2s287+Winding+Way%2C+Bracey%2C+VA+23919%2C+USA!5e0!3m2!1sen!2sin!4v1426312305027\" width=\"400\" height=\"300\" frameborder=\"0\" style=\"border:0\"></iframe>

1 个答案:

答案 0 :(得分:0)

使用stripslashes()从转义字符串中删除斜杠

使用PHP:

$stripped = stripslashes($string);

您的解决方案是:

$my_string = '<iframe src=\"https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d3204.655372160928!2d-78.06299779999999!3d36.5624217!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89adfb01f721a0fb%3A0xd4727f928bfd3f27!2s287+Winding+Way%2C+Bracey%2C+VA+23919%2C+USA!5e0!3m2!1sen!2sin!4v1426312305027\" width=\"400\" height=\"300\" frameborder=\"0\" style=\"border:0\"></iframe>';
echo stripslashes($my_string);