Skip to content

Response: withStatus Example

Terry L edited this page Jun 20, 2020 · 3 revisions

Shieldon\Psr7\Message\Response

Extends Message.

withStatus($code, $reasonPhrase)

Return an instance with the specified status code and, optionally, reason phrase.

  • param string code * The 3-digit integer result code to set.
  • param string reasonPhrase = "" The reason phrase to use with the provided status code
  • return static

Example:

$response = $response->withStatus(599, 'Something went wrong.');

echo $response->getStatusCode();
// Outputs: 599

echo $response->getReasonPhrase();
// Outputs: Something went wrong.
Clone this wiki locally