助手函数token() [F:\phpStudy\WWW\csweb\thinkphp\helper.php]

request类token()方法 [F:\phpStudy\WWW\csweb\thinkphp\library\think\Request.php]

token生成函数可以自定义:

定义全局函数:

1 function token_fun($p){
2     return "token_".$p;
3 }

调用:

 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中:

 

版权声明:本文为natian-ws原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/natian-ws/p/9511113.html