我可以使用PHP将URL变量传递给IFrame吗? [英] Can I Pass a URL variable to an IFrame using PHP?

查看:520
本文介绍了我可以使用PHP将URL变量传递给IFrame吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前我没有使用太多PHP(或根本没有),我有以下代码:

I've not used PHP much (or at all) before, and I have the following code:

<?php
$val = $_GET['ID'];
echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid='$val'    width='100%' scrolling='vertical'></iframe>";
?>

我认为应该可以获取一个URL变量并将其传递给Iframe网址...我的问题是,当我点击页面时,这是打开而不是它:

I think that should be ok to take a URL variable and pass it to an Iframe url...my issue is that when I hit the page this is on instead of it being:

http://sitename.com/whats-on?ID=2

http://sitename.com/whats-on/?ID=2

我不知道之前斜线在哪里??ID来自 - 但我认为这是导致我的问题 - iframe显示页面未找到消息。

I don't know where that slash before /?ID is coming from - but I believe it is causing my problem - the iframe displaying a page not found message.

任何建议表示赞赏。

谢谢

Simon

推荐答案

iFrame只需要一个网址 - 参数可以嵌入到网址中。

iFrames just take a url - and parameters can be embedded in urls just fine.

问题,如果我清楚地理解了这个问题,就是你在混淆你的报价:

The problem, if I understand the question clearly, is that you're mixing up your quotes:

 echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid='$val'
        width='100%' scrolling='vertical'></iframe>";

将输出为

 <iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=' 21254545' 
  width='100%' scrolling='vertical'></iframe>

其中21254545是iframe的一个属性,而不是url的一部分。

where 21254545 is an attribute of the iframe instead of part of the url.

假设您实际上不需要网址中的引号,请将回显线更改为:

Assuming that you don't actually need the quotes in the url, change the echo line to:

echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=$val' width='100%' scrolling='vertical'></iframe>";

它应该有效。

这篇关于我可以使用PHP将URL变量传递给IFrame吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆