ob_get_contents_basic_001.phpt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. --TEST--
  2. Test ob_get_contents() function : basic functionality
  3. --CREDITS--
  4. Iain 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. echo "*** Testing ob_get_contents() : basic functionality ***\n";
  13. // Zero arguments
  14. echo "\n-- Testing ob_get_contents() function with Zero arguments --\n";
  15. /* Buffering not started yet, should return false */
  16. var_dump( ob_get_contents() );
  17. ob_start();
  18. echo "Hello World\n";
  19. $hello = ob_get_contents();
  20. var_dump($hello);
  21. ob_end_flush();
  22. echo "\ncheck that we dont have a reference\n";
  23. ob_start();
  24. echo "Hello World\n";
  25. $hello2 = ob_get_contents();
  26. $hello2 = "bob";
  27. var_dump(ob_get_contents());
  28. ob_end_flush();
  29. echo "\ncheck that contents disappear after a flush\n";
  30. ob_start();
  31. echo "Hello World\n";
  32. ob_flush();
  33. var_dump(ob_get_contents());
  34. ob_end_flush();
  35. echo "\ncheck that no contents found after an end\n";
  36. ob_start();
  37. echo "Hello World\n";
  38. ob_end_flush();
  39. var_dump(ob_get_contents());
  40. echo "Done\n";
  41. ?>
  42. --EXPECT--
  43. *** Testing ob_get_contents() : basic functionality ***
  44. -- Testing ob_get_contents() function with Zero arguments --
  45. bool(false)
  46. Hello World
  47. string(12) "Hello World
  48. "
  49. check that we dont have a reference
  50. Hello World
  51. string(12) "Hello World
  52. "
  53. check that contents disappear after a flush
  54. Hello World
  55. string(0) ""
  56. check that no contents found after an end
  57. Hello World
  58. bool(false)
  59. Done