简体   繁体   English

如何在cakephp 3.x的URL中获取参数而不使用“?”

[英]How to get param without using “?” from url in cakephp 3.x

In this project, I have to get param from url in cakephp 3.x as the project documentation. 在这个项目中,我必须从cakephp 3.x中的URL获取参数作为项目文档。

But it's strange given url in doc, it's like that (New param passing url) 但是给定文档中的URL,这很奇怪,就像这样(传递URL的新参数)

www.example.com/param_name/param_value www.example.com/param_name/param_value

I can get param value in old method parameter passing url like that below. 我可以在传递如下网址的旧方法参数中获取参数值。

www.example.com?param_name=param_value www.example.com?param_name=param_value

But in newer method using "/" instead of "?" 但是在较新的方法中,使用“ /”代替“?” and "=", I don't know how to get that param value. 和“ =”,我不知道如何获取该参数值。

in your routes.php 在你的routes.php中

$routes->connect('/param_name/:param_value',['controller' => 'YourController','action' => 'view'])-> setPass(['param_value']);

in src/Controller/YourController.php 在src / Controller / YourController.php中

public function view($param_value)
{
   echo $param_value;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM