助手函数token() [F:\phpStudy\WWW\csweb\thinkphp\helper.php]php
request类token()方法 [F:\phpStudy\WWW\csweb\thinkphp\library\think\Request.php]web
token生成函数能够自定义:ajax
定义全局函数:thinkphp
1 function token_fun($p){ 2 return "token_".$p; 3 }
调用:app
1 <?php 2 namespace app\index\controller; 3 class Test extends BasicAdmin 4 { 5 public function index() 6 { 7 var_dump(request()->token('__token__', 'token_fun')); 8 //return $this->_view_fetch("/test/index"); 9 } 10 }
显示:函数
ajax请求时调用token()会将token附加到response header中:fetch