对于没有任何实际逻辑的操作方法,我们只需 要直接定义对应的模板文件
访问
http://localhost/app/index.php/home/Form/add
就可以看到表单页面了,我们并没有在控制器里面定义add操作方法,但是很显然,访问是正常的。因为
ThinkPHP3.2.3快速入门
本文档使用 看云 构建 - 13 -
ThinkPHP在没有找到对应操作方法的情况下,会检查是否存在对应的模板文件,由于我们有对应的add模
板文件,所以控制器就直接渲染该模板文件输出了。所以说对于没有任何实际逻辑的操作方法,我们只需
要直接定义对应的模板文件就行了。
D:\LearnWebDevelop\php\thinkphp_3.2.3_full\Application\Home\Controller\FormController.class.php
<?php namespace Home\Controller; use Think\Controller; class FormController extends Controller{ //下面是一个标准的URL访问格式: //http://serverName/index.php/模块/控制器/操作(/参数名/参数值) //http://localhost/thinkphp323/index.php/home/Form/add //http://localhost/thinkphp323/index.php/home/index/hello/name/baby //public function add(){ //$Data = M('Data');// 实例化Data数据模型 //var_dump($Data);exit(); //$result = $Data->find(1); // $this->assign('title',"Form/add"); // $this->display(); //} public function insert(){ //var_dump($_POST); $this->assign('result',"Success!"); $this->display(); } }
D:\LearnWebDevelop\php\thinkphp_3.2.3_full\Application\Home\View\Form\insert.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> __URL__ </title> <meta charset="UTF-8"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> </head> <body> {$result} </body> </html>

 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号