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

__toString() public method

Returns the request as a string.
public __toString ( ) : string
return string The request
    public function __toString()
    {
        try {
            $content = $this->getContent();
        } catch (\LogicException $e) {
            return trigger_error($e, E_USER_ERROR);
        }

        return
            sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
            $this->headers."\r\n".
            $content;
    }

Usage Example

Example #1
0
 /**
  * Transforms an HttpFoundation Request object into a Zend\Http\Request one.
  * 
  * @param HttpFoundationRequest $request HttpFoundation Request
  * 
  * @return ZendRequest 
  */
 public static function toZendRequest(HttpFoundationRequest $request = null)
 {
     if (null === $request) {
         $requestStr = HttpFoundationRequest::createFromGlobals()->__toString();
     } else {
         $requestStr = $request->__toString();
     }
     $requestStr = preg_replace('/\\:(\\s{2,}+)/', ': ', $requestStr);
     return ZendRequest::fromString($requestStr);
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Request::__toString