
SwooleHttpResponse::write 함수를 사용하여 HTTP 헤더를 추가할 수 있습니다.
HTTP 헤더를 추가할 때, `write` 함수를 여러 번 호출할 수 있습니다.
하지만, HTTP 헤더를 추가할 때는 `write` 함수를 한 번만 호출하고, `header` 메소드를 사용하여 헤더를 추가하는 것이 좋습니다.
다음과 같은 코드를 사용하여 HTTP 헤더를 추가할 수 있습니다.
#hostingforum.kr
php
$response = new SwooleHttpResponse();
$response->status(200);
$response->header('Content-Type', 'text/html');
$response->write('HTTP/1.1 200 OK');
$response->end();
또한, `write` 함수를 여러 번 호출할 때는, HTTP 헤더를 추가할 때는 한 번만 호출하고, HTTP 본문을 추가할 때만 여러 번 호출할 수 있습니다.
HTTP 본문을 추가할 때는, `write` 함수를 여러 번 호출하여 본문을 추가할 수 있습니다.
#hostingforum.kr
php
$response = new SwooleHttpResponse();
$response->status(200);
$response->header('Content-Type', 'text/html');
$response->write('HTTP/1.1 200 OK');
$response->write('');
$response->write('');
$response->write('Hello World!');
$response->end();
2025-06-18 07:41