ob_start_basic_unerasable_002.phpt 966 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. ob_start(): Ensure unerasable buffer cannot be erased by ob_clean(), ob_end_clean() or ob_end_flush().
  3. --FILE--
  4. <?php
  5. function callback($string) {
  6. static $callback_invocations;
  7. $callback_invocations++;
  8. return "[callback:$callback_invocations]$string\n";
  9. }
  10. ob_start('callback', 0, false);
  11. echo "All of the following calls will fail to clean/remove the topmost buffer:\n";
  12. var_dump(ob_clean());
  13. var_dump(ob_end_clean());
  14. var_dump(ob_end_flush());
  15. echo "The OB nesting will still be 1 level deep:\n";
  16. var_dump(ob_get_level());
  17. ?>
  18. --EXPECTF--
  19. [callback:1]All of the following calls will fail to clean/remove the topmost buffer:
  20. Notice: ob_clean(): failed to delete buffer of callback (0) in %s on line 11
  21. bool(false)
  22. Notice: ob_end_clean(): failed to discard buffer of callback (0) in %s on line 12
  23. bool(false)
  24. Notice: ob_end_flush(): failed to send buffer of callback (0) in %s on line 13
  25. bool(false)
  26. The OB nesting will still be 1 level deep:
  27. int(1)