Streams stream_context_set_default
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
stream_context_set_default — 기본 스트림 컨텍스트 설정
설명
stream_context_set_default(array $options
): resource
파일 작업(fopen(), file_get_contents() 등...)이 컨텍스트 매개변수 없이 호출될 때마다 사용할 기본 스트림 컨텍스트를 설정합니다. stream_context_create()와 동일한 구문을 사용합니다.
매개변수
options
- 기본 컨텍스트에 대해 설정할 옵션입니다.
메모:
options
는$arr['wrapper']['option'] = $value
형식의 연관 배열의 연관 배열이어야 합니다.
반환 값
기본 스트림 컨텍스트를 반환합니다.
Examples
예제 #1 stream_context_set_default() 예제
<?php
$default_opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar",
'proxy'=>"tcp://10.54.1.39:8000"
)
);
$default = stream_context_set_default($default_opts);
/* Sends a regular GET request to proxy server at 10.54.1.39
* For www.example.com using context options specified in $default_opts
*/
readfile('http://www.example.com');
?>
기타
- stream_context_create() - 스트림 컨텍스트를 만듭니다.
- stream_context_get_default() - 기본 스트림 컨텍스트 검색
- 컨텍스트 옵션이 있는 지원되는 래퍼 목록(지원되는 프로토콜 및 래퍼)