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>
