thinkphp5 - thinkPHP 5 我定义这个路由规则,怎么不管用?

查看:624
本文介绍了thinkphp5 - thinkPHP 5 我定义这个路由规则,怎么不管用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

注意是 thinkphp 5 不是 thinkPHP3

function 位置如下: C:\AppServ\www\t5\yb_application\yb_mokuai\controller\MyController.php

public function echoanumber( $number =1 )
    {
        echo "<title>输出一个数字</title>";
        echo $number;
    }

使用 http://localhost/t5/yb_index/yb_mokuai/my_controller/echoanumber/number/888 可以访问;


但是我在 C:\AppServ\www\t5\yb_application\route.php 加了路由规则:


    'aaa[:number]'=>
    [
        yb_index/yb_mokuai/my_controller/echoanumber/number',
        ['method'=>'get',]
    ]

然后访问 http://localhost/t5/aaa/888 的时候居然 Not Found

请问那里出错了?是路由规则写错了地方,还是写错了???

解决方案

路由规则与路径不匹配,路由中匹配aaa11这样的路由,但是这类路由好像有另外的配置方法,tp组合变量路由

这篇关于thinkphp5 - thinkPHP 5 我定义这个路由规则,怎么不管用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆