我知道我可以像这样传递一个常量参数:
header('位置:page.php?parameter=9999');
但是我怎么能用变量来做呢?像这样:
header('位置:page.php?parameter=$variable'); ???
我知道我可以像这样传递一个常量参数:
header('位置:page.php?parameter=9999');
但是我怎么能用变量来做呢?像这样:
header('位置:page.php?parameter=$variable'); ???
That is correct or you can use session variables
<?php
sesion_start();
//set variable
$_SESSION['juanita'] = 'some value';
?>
<?php
session_start();
//get variable
$newVar = $_SESSION['juanita']; //'some value'
?>
http://www.php.net/manual/en/book.session.php
Just a note, when using variables inside strings use double quotes
header("Location: page.php?parameter=$variable");
It might be better concatenate like SeanWM answer
$variable = 9999;
header('Location: page.php?parameter=' . $variable);
$variable = 9999;
header('Location: page.php?parameter=' . $variable);
Just like you are doing, just set the variable before sending any headers:
<?php
$variable = "Something";
header("Location:page.php?paramter=" . $variable);
?>