test1界面:
<title>testPHP</title><meta http-equiv="content-type" content="text/html; charset = utf-8"><?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%20echo" test2.php>">
第四种传参方式
</a>
</div>
test2界面:
<meta charset="utf-8"><?php $test = $_COOKIE['my']; echo $test; echo '<br/><p>'; session_start(); for($i = 0; $i '; } $testForm = $_POST['my']; echo "表单参数传递".$testForm; echo "第四种传参值".$_GET['urlValue']; ?> </p>
以上就介绍了 PHP四种传参方式,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
php免费学习视频:立即使用
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!











