1. 程式人生 > 實用技巧 >thinkphp傳參第一個迴應函式

thinkphp傳參第一個迴應函式

1.Test.php

<?php


namespace app\sample\controller;


class Test
{
  public function hello($id,$name){
     echo $id;
     echo '|';
     echo $name."<br>";
      return 'hello,world!';
  }
}

 

2.配置路由

<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <[email protected]>
// +----------------------------------------------------------------------


//use think\Route;
Route::get('hello/:id','sample/Test/hello');

  

這裡遇上一個問題,為什麼使用 use think\Route就會錯誤

開啟報錯

檢視報錯

解決方法:

use think\facade\Route;