php.laravel.csrf

概念请自己查


在全局帮助函数库Illuminate\Foundation\helpers.php
中有以下几个函数定义,在看过前两个函数实现可以在
使用中多少有点帮助。

function csrf_field()
{
    return new HtmlString('<input type="hidden" name="_token" value="'.csrf_token().'">');
}



function csrf_token()
{
    $session = app('session');

    if (isset($session)) {
        return $session->token();
    }

    throw new RuntimeException('Application session store not set.');
}



if (! function_exists('app')) {
    /**
     * Get the available container instance.
     *
     * @param  string  $abstract
     * @param  array   $parameters
     * @return mixed|\Illuminate\Foundation\Application
     */
    function app($abstract = null, array $parameters = [])
    {
        if (is_null($abstract)) {
            return Container::getInstance();
        }

        return Container::getInstance()->make($abstract, $parameters);
    }
}

其他请查看

猜你喜欢

转载自www.cnblogs.com/luohaonan/p/9863181.html