PHP四种传参方式

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>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值