Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将参数var/value传递给第二页Php_Php_Variables_Parameter Passing - Fatal编程技术网

将参数var/value传递给第二页Php

将参数var/value传递给第二页Php,php,variables,parameter-passing,Php,Variables,Parameter Passing,我试图将一些参数变量和变量从一个页面x传递到另一个页面y 我的参数化部分如下所示: x?path=1&edu=4&cert= 如何使用php轻松地将这些值传递到另一个页面 注:通常情况下,certvar没有值 例如: 我有一个文件x.php,它正在生成一个url,如:xx.xxx.xxx.xxx/p?path=1&edu=4&cert=。然后我需要在y.php中使用这个url-我怎么做 注意:我无法为此应用程序使用框架 谢谢当收到第x页中的参数时,将它们保存在变量中,并将它们添

我试图将一些参数变量和变量从一个页面x传递到另一个页面y

我的参数化部分如下所示:

x?path=1&edu=4&cert=
如何使用php轻松地将这些值传递到另一个页面

注:通常情况下,
cert
var没有值

例如: 我有一个文件
x.php
,它正在生成一个url,如:
xx.xxx.xxx.xxx/p?path=1&edu=4&cert=
。然后我需要在
y.php
中使用这个
url
-我怎么做

注意:我无法为此应用程序使用框架


谢谢

当收到第x页中的参数时,将它们保存在变量中,并将它们添加到第y页的链接中。有更好的方法,但它们完全取决于你想做什么。 下面是一个简单的例子

x、 php?路径=1&edu=4&cert=

<?php
    $path=$_GET['path'];
    $edu=$_GET['edu'];
    $cert=$_GET['cert'];
    $params = "?path=".$path."&edu=".$edu."&cert=".$cert;
?>
<a href="y.php<?php echo $params ?>">Link to page Y with params obtained from page X</a>

结果将是y.php?path=1&edu=4&cert=

<?php
    $path=$_GET['path'];
    $edu=$_GET['edu'];
    $cert=$_GET['cert'];
    $params = "?path=".$path."&edu=".$edu."&cert=".$cert;
?>
<a href="y.php<?php echo $params ?>">Link to page Y with params obtained from page X</a>

如果您在cert中没有值,这无关紧要,它将作为cert=

try use header location传递

$path=$_GET['path'];
$edu=$_GET['edu'];
if(!isset($_GET['cert'])) header("Location: y.php?edu={$edu}&path={$path}"); 
else $cert = $_GET['cert'];

我不想理解你想要什么,但试一下:

x、 php
您是否提交了任何表单???如果您通过一些事件(如单击按钮)从x.php转到y.php,那么您可以执行ajax调用,并且可以轻松地在另一个页面中接收参数。
就像
//当$x=1时,您的值

<div id="txtHint"></div>
这样,您就可以将参数从一个php页面传递到另一个php页面。
我不知道你是想要这种东西还是别的东西。

你可以使用
$\u SESSION
?!你这样做已经超过他们了。要访问它们,您可以执行以下操作:$edu=$\u GET['edu'];或者使用你的框架提供的任何东西,如果你正在使用的话。我不认为你理解。这些值已经参数化了,我现在尝试在不同的php页面中使用这些var/值-这有意义吗?不,没有。向我们展示什么URI加载什么PHP,以及您希望在该PHP文件中执行什么操作,您尝试了什么(查看
$\u GET
,或者更好的是,
filter\u var
),因此,我有一个生成url的x.PHP,如:。然后我需要在y.php中使用这个url-更好吗?
<div id="txtHint"></div>
<script>
function showHint(path) {

if (path.length == 0) { 
    document.getElementById("txtHint").innerHTML = "";
    return;
} else {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET", "y.php?p=" + path, true);
    xmlhttp.send();
}


 }
</script>`
$path= $_REQUEST["p"];