PHP ob_gzhandler() 함수
예시
페이지에 gzip 압축 추가:
<?php
ob_start("ob_gzhandler");
echo "Hello World!";
?>
정의 및 사용
이 함수는 에 대한 콜백으로 전달하기 위한 것 ob_start()
입니다. 브라우저에서 지원하는 압축 알고리즘을 사용하여 출력 버퍼의 내용을 압축하고 압축된 내용을 반환합니다. 또한 사용된 압축 알고리즘을 나타내는 HTTP 헤더를 보냅니다.
통사론
다음 에 대한 콜백으로 사용되는 경우 ob_start()
:
ob_start("ob_gzhandler");
단독으로 사용하는 경우:
ob_gzhandler(buffer, phase);
매개변수 값
Parameter | Description |
---|---|
buffer | The contents of the output buffer |
phase | A bitmask which may have any number of the following flags: PHP_OUTPUT_HANDLER_START - If the output buffer was just created PHP_OUTPUT_HANDLER_FLUSH - If the output buffer is currently being flushed PHP_OUTPUT_HANDLER_FINAL - If the output buffer will be deleted right after this operation |
기술적 세부 사항
반환 값: | 압축된 내용을 포함하는 문자열을 반환합니다. |
---|---|
PHP 버전: | 4.0.4+ |
❮ PHP 출력 제어 기능