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

1.传单个参数

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

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

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

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

2.传多个参数

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

 第一种:传id,和status

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

status参数紧接其后写即可

后台获取两个参数

1
2
$id=$_GET['id'];
$status=$_GET['status'];

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

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

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

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

相关文章:

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