There’s a string like:
HTTP/1.1 200 OK
Date: Thu, 15 Dec 2011 12:23:25 GMT
Server: Microsoft-IIS/6.0
Content-Length: 2039
Content-Type: text/html
<!DOCTYPE html>
...
Is is possible to send it as headers + body with one command? I know you can use header and echo/print/printf to output body, but since the string I have is exactly in the form I’ve written, to use these functions I’d have to parse it into headers and body.
I’ve tried writing to php://output, but it seems to think headers are the body.
No, you have to use
header(). You could split the string into lines, walk the lines one by one callingheader()for each one until you meet the empty line and then echo the rest of it.