ITPub博客

首页 > IT职业 > IT职场 > ResponseTrait.php

ResponseTrait.php

IT职场 作者:ppdlc 时间:2021-09-09 09:16:03 0 删除 编辑

 

namespace IlluminateHttp;

 

trait ResponseTrait

{// a real trait  be set

   

    public function status()

    {

        return $this->getStatusCode();

    }// Get the status code for the response.

 

   

    public function content()

    {

        return $this->getContent();// get Content

    }// Get the content of the response.

 

   

    public function header($key, $value, $replace = true)

    {

        $this->headers->set($key, $value, $replace);

 

        return $this;

    }// Set a header on the response.

 

   

    public function withHeaders(array $headers)

    {

        foreach ($headers as $key => $value) {

            $this->headers->set($key, $value);

        }

 

        return $this;

    }//with Headers

 

   

    public function cookie($cookie)

    {

        return call_user_func_array([$this, 'withCookie'], func_get_args());

    }//Add a cookie

 

   

    public function withCookie($cookie)

    {

        if (is_string($cookie) && function_exists('cookie')) {

            $cookie = call_user_func_array('cookie', func_get_args());

        }

 

        $this->headers->setCookie($cookie);

 

        return $this;

    }//with cookie

}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1812/viewspace-2801548/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: php - 函数
请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    105
  • 访问量
    704