【发布时间】:2015-11-06 19:19:02
【问题描述】:
我想在控制器中使用 if..else 语句执行操作,该语句分析路由并采取相应措施。这可能吗?
路线:blog\post\{tag} or blog\post.
tag 是一个数组,因此很可能它看起来像 ?tag=1,2,3,4,51
controller action diplaypost()
{
if (!isset($_GET['tag'])) {do smth; //case of route blog\post}
else {do smth; //case of route blog\post\{tag} }
}
【问题讨论】:
-
这可能适用:symfony.com/doc/current/book/… 但我认为你真正需要的只是给标签一个默认值 null。