test1界面:
<html>
<head>
<title>testPHP</title>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
</head>
<body>
<?php
//第一种设置传参方式,通过cookie
setcookie('my','yefeng');
//第二种传参方式,通过设置服务器session值传递参数
session_start();
$_SESSION["temp"] = array('456','789');
$test = "我是一个测试变量";
?>
<div id = "test1" style = "height:10%; border:1px solid red">
//第一种传参方式
</div>
<div id = "test2" style = "height:10%; border:1px solid red; margin-top:5%">
//第二种传参方式
</div>
<div id = "test3" style = "height:10%; border:1px solid red; margin-top:5%">
//第三种传参方式
<form action = "test2.php" method = "post">
<input type = "text" name = "my"/>
<input type = "submit" name = "submit" value = "提交" />
</form>
</div>
<div id = "test4" style = " height:10%; border:1px solid red; margin-top:5%">
<a href = "<?php echo"test2.php?urlValue=".$test4?>">
第四种传参方式
</a>
</div>
</body>
</html>
test2界面:
<html>
<head>
<meta charset = 'utf-8' />
<?php
$test = $_COOKIE['my'];
echo $test;
echo '<br/>';
session_start();
for($i = 0; $i < 2; $i ++){
echo $_SESSION['temp'][$i].'<br/>';
}
$testForm = $_POST['my'];
echo "表单参数传递".$testForm;
echo "第四种传参值".$_GET['urlValue'];
?>
</head>
<body></body>
</html>