thinkphp中简单的控制器使用

1.在路由(route.php)中定义一条路由

Route::rule('new/:name/:id','index/News/read');

2.在index下的controller控制器中新建一个News控制器

<?php
/**
 * Created by PhpStorm.
 * User: yly
 * Date: 2020/2/12
 * Time: 13:43
 */
namespace  app\index\controller;

class News{
  public function  read($name,$id){
      return 'hello'.$name.':  您的学号是: '.$id;
  }
}

3.在浏览器中调用如图所示

猜你喜欢

转载自www.cnblogs.com/yaoliuyang/p/12298824.html
今日推荐