fengting

thinkphp中URL传参数的几种方式

2015-04-07 21:27  pengfengting~  阅读(26379)  评论(0编辑  收藏  举报

在thinkphp中,url传参合asp.net中原理类似,下面就单个参数和多个参数传递方式进行一个简单讲解

1.传单个参数

 单个参数这种比较简单,例如 想像edit操作里面传递一个id值,如下写法__URL__/edit/id/1

http://localhost/index.php/user/edit/id/1

id和其值1要分别位于/后面

后台获取id通过    $id=$_GET[\'id\']   即可获取其具体值。

2.传多个参数

传多个参数相对比较麻烦一点,可以通过两种方式

 第一种:传id,和status

http://localhost/index.php/user/edit/id/1/status/2

status参数紧接其后写即可

后台获取两个参数

$id=$_GET[\'id\'];
$status=$_GET[\'status\'];

还有一种比较常规的用法如下:

http://localhost/index.php/user?id=1&&status=2

但这种方式不可以通过$_GET[\'id\']的方式来获取,需要通过如下方式

$id=$_REQUEST[\'id\'];
$status=$_REQUEST[\'status\'];
//能通过$_GET[\'ID\']获取的值,通过$_REQUEST[\'id\']均可以获得。

  

 

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
  • 2022-12-23
  • 2021-11-30
  • 2022-01-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
  • 2021-07-10
  • 2021-10-12
相关资源
相似解决方案