Want more features on Pastebin? Sign Up, it's FREE!
Guest

Robin

By: a guest on Sep 12th, 2007  |  syntax: PHP  |  size: 1.25 KB  |  views: 427  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.   while (ob_get_level()>0) {
  34.     ob_end_flush();
  35.   }
  36. }
  37.  
  38. echo "\n ---> Test comma delimited strings: \n";
  39. checkAndClean();
  40.  
  41. checkAndClean();
  42.  
  43. var_dump(ob_start("f,C::g,f,C::g"));
  44. checkAndClean();
  45. ?>
  46. --EXPECTF--
  47.  ---> Test comma delimited strings:
  48. f[call:1; len:34] - bool(true)
  49. Array
  50. (
  51.     [0] => f
  52. )
  53.  
  54. f[call:3; len:68] - f[call:2; len:47] - bool(true)
  55. Array
  56. (
  57.     [0] => f
  58.     [1] => f
  59. )
  60.  
  61.  
  62. f[call:5; len:150] - C::g[call:2; len:125] - f[call:4; len:103] - C::g[call:1; len:79] - bool(true)
  63. Array
  64. (
  65.     [0] => f
  66.     [1] => C::g
  67.     [2] => f
  68.     [3] => C::g
  69. )
clone this paste RAW Paste Data