<pre name="code" class="html"> public function show(){ echo "访问了index模块下的show方法!!"; echo "欢迎你".$_GET['name'].'你的年龄是'.$_GET['age']; $m=M('user'); $id=$_GET['id']; $arr=$m->where("id=$id")->getField('username'); //var_dump($arr); $this->assign('data',$arr); $this->display(); } $this->assign('data',$arr); 分配数据给data标示 给前端 $this->display(); 调用前台模板 <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> </head> <body> <h1>helloworld----<{$data}></h1> </body> </html> 访问接口: http://localhost/thinkphp/index.php/Index/show/id/7