-
Notifications
You must be signed in to change notification settings - Fork 1
PSR 7: Response Example
Terry L edited this page Jun 20, 2020
·
4 revisions
Namespace
Shieldon\Psr7\Response-
param
intstatus= 200Response HTTP status code. -
param
arrayheaders= []Response headers. -
param
StreamInterface|stringbody= ""Response body. -
param
stringversion= "1.1"Response protocol version. -
param
stringreason= "OK"Reasponse HTTP reason phrase.
Example:
$response = new \Shieldon\Psr7\Response();-
return
int
Example:
$statusCode = $response->getStatusCode();
echo $statusCode
// Outputs: 200-
param
stringcode*The 3-digit integer result code to set. -
param
stringreasonPhrase= ""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.-
return
string
Example:
$reasonPhrase = $response->getReasonPhrase();
echo $reasonPhrase
// Outputs: OKcomposer require shieldon/psr-httpShieldon PSR HTTP implementation written by Terry L. from Taiwan.
