Header in Response

I’m reading doc of Slin4 and I trying do this -
$response = new Response();
$response->withHeader(‘Location’, ‘https://www.example.com’);
print_r($response->getHeaders());
But it print nothing. I try googling and i didn’t understand what is wrong

The PSR-7 request and response headers are “immutable”. So try this:

$response = $response->withHeader('Location', 'https://www.example.com');

Hmmm, it is working! Thank you. I’m in deep shock. This method gives back the whole object of response?

Yes, it creates a “clone”, changes or adds the new value and returns the cloned object.