From 84ba9a1654ca0125257e3333db3d09dae32251e4 Mon Sep 17 00:00:00 2001 From: Patrick Louys Date: Wed, 28 Jan 2015 22:26:47 +0100 Subject: [PATCH] update header() call to fix overwrite header bug --- 04-http.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/04-http.md b/04-http.md index 660eece..cc33fe3 100644 --- a/04-http.md +++ b/04-http.md @@ -35,7 +35,7 @@ To actually send something back, you will also need to add the following snippet ```php foreach ($response->getHeaders() as $header) { - header($header); + header($header, false); } echo $response->getContent(); @@ -43,6 +43,8 @@ echo $response->getContent(); This will send the response data to the browser. If you don't do this, nothing happens as the `Response` object only stores data. This is handled differently by most other HTTP components where the classes send data back to the browser as a side-effect, so keep that in mind if you use another component. +The second parameter of `header()` is false because otherwise existing headers will be overwritten. + Right now it is just sending an empty response back to the browser with the status code `200`; to change that, add the following code between the code snippets from above: ```php