首页 > IT职业 > IT职场 > ResponseTrait.php
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/ ,如需转载,请注明出处,否则将追究法律责任。