1

我有一个 php 网页和一个 iframe。前任:

php 页面的 url http://www.ex.com/index.php?one=anumber

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body> <iframe id="34" class="ddd" src="two.php"></iframe>
</body>
</html>

那么在 two.php 中使用什么 php 代码来从父 url 中获取变量 one 呢?

4

2 回答 2

1

最简单的是将完整的查询字符串发送到 two.php,就像这样

<iframe id="34" class="ddd" src="two.php?<?=$_SERVER['QUERY_STRING']?>"></iframe>
于 2013-02-10T16:18:08.863 回答
0

明白了……所以

这就是我所做的,我是 php 的菜鸟,但它有效

我创建了 3 个 php 文件,这就是他们拥有的代码

index.php 是一样的

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body> <iframe id="34" class="ddd" src="two.php"></iframe>
</body>
</html>

在 two.php 中是

<?php
   //Getting the parent window parameters
    $getURLVar = str_replace("?","",strrchr($_SERVER['HTTP_REFERER'],"?"));
   // refreshing the iframe with the variables at the end
    header("Location: 3.php?$getURLVar");
?>

在 3.php 中是

<?php 
$pageis888 = $_GET["one"];
?>

我知道有更好的解决方案,但这也适用:P

于 2013-02-11T00:57:11.750 回答