mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
增加token助手函数 用于在页面快速显示令牌
This commit is contained in:
13
helper.php
13
helper.php
@@ -523,3 +523,16 @@ if (!function_exists('halt')) {
|
||||
throw new \think\exception\HttpResponseException(new Response);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('token')) {
|
||||
/**
|
||||
* 生成表单令牌
|
||||
* @param string $name 令牌名称
|
||||
* @param mixed $type 令牌生成方法
|
||||
*/
|
||||
function token($name = '__token__', $type = 'md5')
|
||||
{
|
||||
$token = Request::instance()->token($name, $type);
|
||||
return '<input type="hidden" name="' . $name . '" value="' . $token . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user