Guest User

Simple test case showing flush() wrecking PHP and Apache

a guest
Dec 28th, 2020
46
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library.php:
  2. ------------
  3. <?php
  4.  
  5. function foo() {
  6. }
  7.  
  8. ?>
  9.  
  10.  
  11. error.php:
  12. ----------
  13. <?php
  14.  
  15. error_reporting(E_ALL);
  16. require_once 'library.php';
  17.  
  18. echo 'I will deal with a 500 error and show a pretty error message';
  19.  
  20. ?>
  21.  
  22.  
  23. test.php:
  24. ---------
  25. <?php
  26.  
  27. error_reporting(E_ALL);
  28. require_once 'library.php';
  29.  
  30. $test = 1; // Try all 3 tests
  31.  
  32. if ($test == 1) {
  33.     header('Foo: Bar');
  34.     flush();
  35.     echo 'I worked absolutely fine';
  36. }
  37.  
  38. if ($test == 2) {
  39.     header('Foo : Bar'); // Only change
  40.     echo 'I went wrong but did so gracefully';
  41. }
  42.  
  43.  
  44. if ($test == 3) {
  45.     header('Foo : Bar');
  46.     flush(); // Only change
  47.     echo 'I fell to pieces in a horrendous and nonsensical way';
  48. }
  49.  
  50. ?>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×