thinkphp學習小記

來源:互聯網
上載者:User

標籤:ar   io   使用   sp   for   on   bs   cti   代碼   

1.載入模板時報錯:Class ‘Model‘ not found FILE: E:\wamp\www\thinkphp\Application\Home\Model\FormModel.class.php  LINE: 7
解決方案:namespace Home\Model; use Think\Model; 加上命名空間。並且必須放到代碼的首行,不然會報錯並且不起作用。
new Model()方法出錯:$Model = new Model() 提示:Class ‘Home\Controller\Model‘ not found
錯誤位置:FILE: E:\wamp\www\kschao\wwwroot\Application\Home\Controller\IndexController.class.php  LINE: 21
getLastSql()出錯:提示:Call to a member function getLastSql() on a non-object
代碼如下:$student = new Model(‘student‘);$result=$student->select();echo $result->getLastSql();
改為$student = new Model(‘student‘);$result=$student->select();echo $student->getLastSql();就ok了。原因是只能對模型使用getLastSql()方法

 

2.路由
step1:開啟路由 在項目配置中而不是在系統配置中
step2:設定路由規則 路由規則分為正則路由和規則路由。

3.php緩衝?????

3.空模板和空操作

4.前置和後置操作
function _before_index()
function _after_index()

4.頁面跳轉和頁面重新導向
內建兩個跳轉方法error和success,分別用於錯誤跳轉和成功跳轉。會自動跳轉到指定的地址,但是url地址不會發生變化
內建redirect方法實現頁面的重新導向,重新導向後會改變當前的url地址。

5.自動驗證和自動完成
自動驗證:protected $_validate()=array() 自動完成:protected $_auto=array()

 

thinkphp學習小記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.