使用ThinkPHP實現生成 校驗驗證碼功能

2022-06-10 18:21:08 字數 581 閱讀 7116

首先了解父類verity.class.php(thinkphp/library/think/verity.class.php)中的一些函式

1:check() 校驗驗證碼是否正確

2:entry()輸出驗證碼並把驗證碼的值儲存的session中

3:authcode() 加密驗證碼(此方法在check()方法中被呼叫)

控制器生成驗證碼**:

//

驗證碼function

verifyimg()

前台顯示驗證碼

<

img

src="<>/verifyimg"

onclick

= "this.src='<>/verifyimg/'+math.random()"

alt="驗證碼"

/>

控制器校驗證碼(以登陸為例)

//

登陸function

login()

else

}//呼叫view檢視

$this->display();

}

thinkphp 使用U方法自動生成URL超連結

u 方法是 thinkphp 內建的乙個快捷方法,可以根據系統 url 模式配置動態的生成智慧型的 url 位址。由於 thinkphp 支援各種不同的 url 模式,另外還有分組模式,因此當環境發生變化時,有時候可能會改變 url 模式,而 u 方法正是解決不同配置情況下的 url 統一問題。除了...

thinkphp自動生成類

模型類 cqhmodel.class.php namespace cqh model use think model class cqhmodel extends model 生成控制器 public function gcontroller return true 生成模型 public func...

thinkphp的自動生成

第一,在index.php裡定義 define bind module admin 自動生成admin目錄下的結構 預設生成indexcontroller define build controller list index,user,menu 指定生成indexcontroller,usercon...