将 URI 段传递给您的方法
Passing URI Segments to your methods
我正在阅读 codeigniter-3 教程,但我不完全理解它们的意思:
"If you are using the URI Routing feature, the segments passed to your method will be the re-routed ones."
在"Passing URI Segments to your methods"
之下
显示代码:
<?php
class Products extends CI_Controller {
public function shoes($sandals, $id)
{
echo $sandals;
echo $id;
}
}
http://www.codeigniter.com/user_guide/general/controllers.html
段是传递给函数的参数吗?它们将被重新路由是什么意思?
我检查了 URI 路由功能,但仍然不明白。
任何人都可以解释他们的意思吗?
对于您的情况,我建议您继续阅读 URI Routing,以获取有关正在发生的事情的更多信息。
但是为了回答您的问题,例如,如果您正在定义新的 URI 以根据需要更改 URL,那么通过调用 shoes($sandals, $id)
,您将获得在重新路由过程,而不是原来的过程。
换句话说,如果您已尝试重新路由您的 URI
from index.php/Product/shoes/blue/10 to index .php/Product/shoes/green/10
然后通过调用 shoes($sandals, $id)
你会得到 green 和 10,正如你提到的,注意蓝色不会然后显示。
我正在阅读 codeigniter-3 教程,但我不完全理解它们的意思:
"If you are using the URI Routing feature, the segments passed to your method will be the re-routed ones."
在"Passing URI Segments to your methods"
之下显示代码:
<?php
class Products extends CI_Controller {
public function shoes($sandals, $id)
{
echo $sandals;
echo $id;
}
}
http://www.codeigniter.com/user_guide/general/controllers.html
段是传递给函数的参数吗?它们将被重新路由是什么意思? 我检查了 URI 路由功能,但仍然不明白。 任何人都可以解释他们的意思吗?
对于您的情况,我建议您继续阅读 URI Routing,以获取有关正在发生的事情的更多信息。
但是为了回答您的问题,例如,如果您正在定义新的 URI 以根据需要更改 URL,那么通过调用 shoes($sandals, $id)
,您将获得在重新路由过程,而不是原来的过程。
换句话说,如果您已尝试重新路由您的 URI
from index.php/Product/shoes/blue/10 to index .php/Product/shoes/green/10
然后通过调用 shoes($sandals, $id)
你会得到 green 和 10,正如你提到的,注意蓝色不会然后显示。