Guest User

Robin

a guest
Sep 12th, 2007
469
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --TEST--
  2. ob_start with comma delimited strings
  3. --FILE--
  4. <?php
  5. /*
  6.  * proto bool ob_start([ string|array user_function [, int chunk_size [, bool erase]]])
  7.  * Function is implemented in main/output.c
  8. */
  9.  
  10. function f($string) {
  11.     static $i=0;
  12.     $i++;
  13.     $len = strlen($string);
  14.     return "f[call:$i; len:$len] - $string\n";
  15. }
  16.  
  17. Class C {
  18.     public $id = 'none';
  19.  
  20.     function __construct($id) {
  21.         $this->id = $id;
  22.     }
  23.  
  24.     static function g($string) {
  25.         static $i=0;
  26.         $i++;
  27.         $len = strlen($string);
  28.         return "C::g[call:$i; len:$len] - $string\n";
  29.     }
  30. }
  31.  
  32. function checkAndClean() {
  33.   print_r(ob_list_handlers());
  34.   while (ob_get_level()>0) {
  35.     ob_end_flush();
  36.   }
  37. }
  38.  
  39. echo "\n ---> Test comma delimited strings: \n";
  40. var_dump(ob_start("f"));
  41. checkAndClean();
  42.  
  43. var_dump(ob_start("f,f"));
  44. checkAndClean();
  45.  
  46. var_dump(ob_start("f,C::g,f,C::g"));
  47. checkAndClean();
  48. ?>
  49. --EXPECTF--
  50.  ---> Test comma delimited strings:
  51. f[call:1; len:34] - bool(true)
  52. Array
  53. (
  54.     [0] => f
  55. )
  56.  
  57. f[call:3; len:68] - f[call:2; len:47] - bool(true)
  58. Array
  59. (
  60.     [0] => f
  61.     [1] => f
  62. )
  63.  
  64.  
  65. f[call:5; len:150] - C::g[call:2; len:125] - f[call:4; len:103] - C::g[call:1; len:79] - bool(true)
  66. Array
  67. (
  68.     [0] => f
  69.     [1] => C::g
  70.     [2] => f
  71.     [3] => C::g
  72. )
RAW Paste Data