1--TEST-- 2Test ob_get_contents() function : basic functionality 3--CREDITS-- 4Iain Lewis <ilewis@php.net> 5--FILE-- 6<?php 7/* Prototype : proto string ob_get_contents(void) 8 * Description: Return the contents of the output buffer 9 * Source code: main/output.c 10 * Alias to functions: 11 */ 12 13 14echo "*** Testing ob_get_contents() : basic functionality ***\n"; 15 16// Zero arguments 17echo "\n-- Testing ob_get_contents() function with Zero arguments --\n"; 18/* Buffering not started yet, should return false */ 19var_dump( ob_get_contents() ); 20 21ob_start(); 22echo "Hello World\n"; 23$hello = ob_get_contents(); 24var_dump($hello); 25ob_end_flush(); 26 27 28echo "\ncheck that we dont have a reference\n"; 29ob_start(); 30echo "Hello World\n"; 31$hello2 = ob_get_contents(); 32$hello2 = "bob"; 33var_dump(ob_get_contents()); 34ob_end_flush(); 35 36echo "\ncheck that contents disappear after a flush\n"; 37ob_start(); 38echo "Hello World\n"; 39ob_flush(); 40var_dump(ob_get_contents()); 41ob_end_flush(); 42 43echo "\ncheck that no contents found after an end\n"; 44ob_start(); 45echo "Hello World\n"; 46ob_end_flush(); 47var_dump(ob_get_contents()); 48 49 50echo "Done\n"; 51?> 52--EXPECTF-- 53*** Testing ob_get_contents() : basic functionality *** 54 55-- Testing ob_get_contents() function with Zero arguments -- 56bool(false) 57Hello World 58string(12) "Hello World 59" 60 61check that we dont have a reference 62Hello World 63string(12) "Hello World 64" 65 66check that contents disappear after a flush 67Hello World 68string(0) "" 69 70check that no contents found after an end 71Hello World 72bool(false) 73Done