
stream_context_set_option 함수의 세 번째 인자인 'option'에 값을 넣는 방법은 다음과 같습니다.
- stream_context_set_option($context, 'http', 'header', 'User-Agent: MyAgent');
- stream_context_set_option($context, 'http', 'method', 'POST');
위의 예제에서 'http'은 프로토콜을 의미하고 'header'는 HTTP 요청 헤더를 의미합니다. 'User-Agent: MyAgent'은 HTTP 요청 헤더에 User-Agent 값을 추가하는 예제입니다.
또한, 'method' 옵션을 사용하여 HTTP 요청 메서드를 변경할 수 있습니다. 위의 예제에서 'POST'는 HTTP 요청 메서드를 POST로 변경합니다.
stream_context_set_option 함수는 HTTP 요청 헤더나 메서드를 변경하는 데 사용할 수 있습니다.
2025-04-21 17:09