ob_start callback에 대한 설명
(PHP 4, PHP 5)
ob_start — 출력 버퍼링을 켭니다
bool ob_start ([ callable $output_callback = NULL [, int $chunk_size = 0 [, int $flags = PHP_OUTPUT_HANDLER_STDFLAGS ]]] )
출력 버퍼링을 켭니다. 출력 버퍼링을 활성화한 동안, (헤더를 제외한) 스크립트의 모든 출력을 내부 버퍼에 저장하고, 실제로 전송하지 않습니다.
이 내부 버퍼의 내용은 ob_get_contents()를 이용해서 문자열 변수로 복사할 수 있습니다. 내부 버퍼에 들어있는 내용을 출력하려면, ob_end_flush()를 사용하십시오. 또는, ob_end_clean()로 버퍼 내용을 출력하지 않고 지울 수 있습니다.
인수 ¶
output_callback
선택적인 output_callback 함수를 지정할 수 있습니다. 이 함수는 문자열을 인수로 받고, 문자열을 반환해야 합니다. 이 함수는 (ob_flush(), ob_clean() 등의 함수로) 출력 버퍼를 보내거나(전송) 비울 때, 또는 요청 마지막에 출력 버퍼를 브라우저로 보낼 때 호출됩니다. output_callback을 호출 할 때 출력 버퍼의 내용을 인수로 보내고, 브라우저로 전송할 새 출력 버퍼를 결과로 반환하여 작동합니다. output_callback이 호출할 수 있는 함수가 아니라면, 이 함수는 FALSE를 반환합니다. 다음이 콜백 형태입니다:
bool handler ( string $buffer [, int $phase ] )
buffer
출력 버퍼의 내용.
phase
PHP_OUTPUT_HANDLER_* 상수의 비트 마스크.
output_callback이 FALSE를 반환하면, 원 입력이 브라우저로 전송됩니다.
output_callback 인수는 NULL 값을 넘겨서 지나갈 수 있습니다.
ob_end_clean(), ob_end_flush(), ob_clean(), ob_flush(), ob_start()는 콜백 함수에서 호출할 수 없습니다. 이 함수들을 콜백 함수에서 호출하면, 그 동작은 정의되어 있지 않습니다. 버퍼 내용을 지우고 싶으면, 콜백 함수에서 ""(빈 문자열)을 반환하면 됩니다. 또한, 출력 버퍼링 함수를 사용하는 print_r($expression, true), highlight_file($filename, true) 등의 함수도 콜백 함수에서 호출할 수 없습니다.
위 예제는 php.net에서 가져온것이고 거기에 제 설명을 간미한것입니다.
<?php
function callback($buffer)
{
// 모든 apples를 oranges로 치환합니다.
return (str_replace("apples", "oranges", $buffer));
}
ob_start("callback");
?>
<html>
<body>
<p>It's like comparing apples to oranges.</p>
</body>
</html>
<?php
ob_end_flush();
?>
output :
<html>
<body>
<p>It's like comparing oranges to oranges.</p>
</body>
</html>
callback함수 없이 실행 할경우
<?php
ob_start();
?>
<html>
<body>
<p>It's like comparing apples to oranges.</p>
</body>
</html>
<?php
$print = ob_get_contents();
ob_end_clean();
echo $print;
?>
output :
<html>
<body>
<p>It's like comparing apples to oranges.</p>
</body>
</html>
게시글 목록
| 번호 | 제목 |
|---|---|
| 27980 | |
| 7164 | |
| 31729 | |
| 31726 | |
| 31725 | |
| 31720 | |
| 31711 | |
| 7159 | |
| 27974 | |
| 19734 | |
| 19730 | |
| 19729 |
PHP
[알고리즘] 배열 역순
|
| 27969 | |
| 7142 | |
| 19728 |
jQuery
remove()를 이용하여 엘리먼트 삭제하기
|
| 19725 | |
| 7130 | |
| 19722 |
jQuery
동일 엘리먼트 순번 알아내기
2
|
| 19719 | |
| 7124 | |
| 19718 | |
| 19717 | |
| 19716 |
jQuery
position() 메서드 객체에 대한 좌표값
|
| 19715 | |
| 7122 | |
| 30959 | |
| 19714 | |
| 31710 |
jQuery Mobile
jQuery Mobile 강좌 19. Select Menus
|
| 31709 |
jQuery Mobile
jQuery Mobile 강좌 18. Text Inputs
|
| 19713 | |
| 7117 | |
| 19712 | |
| 7111 | |
| 31708 |
jQuery Mobile
jQuery Mobile 강좌 17. Form Basic
|
| 31707 |
jQuery Mobile
jQuery Mobile 강좌 16. Filters
|
| 19710 | |
| 31706 |
jQuery Mobile
jQuery Mobile 강좌 15. List Content
|
| 31705 |
jQuery Mobile
jQuery Mobile 강좌 14. List Views
|
| 31704 |
jQuery Mobile
jQuery Mobile 강좌 13. Layout Grids
|
| 19709 | |
| 19707 | |
| 31703 |
jQuery Mobile
jQuery Mobile 강좌 12. Tables
|
| 19706 |
jQuery
class가 있는지 없는지 체크하기
|
| 31702 |
jQuery Mobile
jQuery Mobile 강좌 11. Collapsibles
|
| 19705 |
PHP
배열에서 중복 값 없애기
|
| 31701 |
jQuery Mobile
jQuery Mobile 강좌 10. Panels
|
| 19704 | |
| 31700 |
jQuery Mobile
jQuery Mobile 강좌 9. Navigation Bars
|
| 31699 |
jQuery Mobile
jQuery Mobile 강좌 8. Toolbars
|
| 31698 |
jQuery Mobile
jQuery Mobile 강좌 7. Popups
|
| 7107 | |
| 19703 |
JavaScript
str_pad 자릿수만큼 특정문자로 채우기
|
| 31697 |
jQuery Mobile
jQuery Mobile 강좌 6. Icons
|
| 31696 |
jQuery Mobile
jQuery Mobile 강좌 5. Buttons
|
| 19702 | |
| 19701 | |
| 31695 |
jQuery Mobile
jQuery Mobile 강좌 4. Transitions
|
| 27965 | |
| 31694 |
jQuery Mobile
jQuery Mobile 강좌 3. Pages
|
| 19700 | |
| 31693 |
jQuery Mobile
jQuery Mobile 강좌 2. Install
|
| 19699 | |
| 31692 |
jQuery Mobile
jQuery Mobile 강좌 1. Introduction
|
| 31691 |
jQuery Mobile
jQuery Mobile 강좌 0.home
|
| 19698 | |
| 19697 | |
| 19696 |
jQuery
마우스 오버 위치에 따라 툴팁 생성 및 자동 이동
|
| 19694 | |
| 19693 |
jQuery
제이쿼리 동적으로 생성된 객체에 이벤트 생성하기
|
| 19692 | |
| 19691 | |
| 19690 |
JavaScript
shuffle 배열섞기
|
| 19689 |
jQuery
제이쿼리 모음 사이트
|
| 19688 |
PHP
1원팁] IP 대역 비교
|
| 19687 | |
| 7105 | |
| 30955 | |
| 7100 | |
| 19681 |
PHP
input 쉽게 관리하기
5
|
| 7097 | |
| 19678 |
JavaScript
서버시간을 사용한 전자시계
2
|
| 7089 | |
| 7086 | |
| 7084 | |
| 7082 | |
| 19677 | |
| 30953 | |
| 7080 | |
| 7077 | |
| 7071 | |
| 7070 | |
| 7066 | |
| 19676 |
JavaScript
구글 웹사이트 번역기를 내 사이트에 달기
|
| 19674 | |
| 27961 | |
| 7063 | |
| 7061 | |
| 19669 | |
| 7060 | |
| 20842 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기