Symfony\Component\HttpFoundation\Response::__toString PHP Method

__toString() public method

The string representation of the Response is the same as the one that will be sent to the client only if the prepare() method has been called before.
See also: prepare()
public __toString ( ) : string
return string The Response as an HTTP string
    public function __toString()
    {
        return
            sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)."\r\n".
            $this->headers."\r\n".
            $this->getContent();
    }

Usage Example

Example #1
0
 public function __toString()
 {
     $this->headers->set('Content-Length', strlen($this->getContent()));
     return parent::__toString();
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Response::__toString