fpassthru_basic.phpt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. --TEST--
  2. Test fpassthru() function: Basic functionality
  3. --FILE--
  4. <?php
  5. $file_name = __DIR__."/passthru.tmp";
  6. $write_handle = fopen($file_name, "w");
  7. $string = "Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^
  8. Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^\n";
  9. if(substr(PHP_OS, 0, 3) == "WIN") {
  10. $string = str_replace("\r",'', $string);
  11. }
  12. fwrite($write_handle, $string);
  13. fclose($write_handle);
  14. $read_handle = fopen($file_name, "r");
  15. echo "*** Test basic functionality of fpassthru() function ***\n";
  16. echo "\n-- Before seek operation --\n";
  17. var_dump( fpassthru($read_handle) );
  18. echo "\n-- After seeking position to 0 --\n";
  19. fseek($read_handle, 0);
  20. var_dump( fpassthru($read_handle) );
  21. echo "\n-- After seeking position to 3 --\n";
  22. fseek($read_handle, 3);
  23. var_dump( fpassthru($read_handle) );
  24. echo "\n-- After seeking position to 13 --\n";
  25. fseek($read_handle, 13);
  26. var_dump( fpassthru($read_handle) );
  27. echo "\n-- After seeking position to 14 --\n";
  28. fseek($read_handle, 14);
  29. var_dump( fpassthru($read_handle) );
  30. echo "\n-- After seeking position to 23 --\n";
  31. fseek($read_handle, 23);
  32. var_dump( fpassthru($read_handle) );
  33. echo "\n-- After seeking position to 34 --\n";
  34. fseek($read_handle, 34);
  35. var_dump( fpassthru($read_handle) );
  36. echo "\n-- After seeking position to 1000 --\n";
  37. fseek($read_handle, 1000);
  38. var_dump( fpassthru($read_handle) );
  39. fclose($read_handle);
  40. echo "*** Done ***\n";
  41. ?>
  42. --CLEAN--
  43. <?php
  44. unlink(__DIR__."/passthru.tmp");
  45. ?>
  46. --EXPECT--
  47. *** Test basic functionality of fpassthru() function ***
  48. -- Before seek operation --
  49. Hello, world
  50. , abcdefg adsdsfdf
  51. 8u2394723947 $%$%#$%#$%#^#%^
  52. Hello, world
  53. , abcdefg adsdsfdf
  54. 8u2394723947 $%$%#$%#$%#^#%^
  55. int(132)
  56. -- After seeking position to 0 --
  57. Hello, world
  58. , abcdefg adsdsfdf
  59. 8u2394723947 $%$%#$%#$%#^#%^
  60. Hello, world
  61. , abcdefg adsdsfdf
  62. 8u2394723947 $%$%#$%#$%#^#%^
  63. int(132)
  64. -- After seeking position to 3 --
  65. lo, world
  66. , abcdefg adsdsfdf
  67. 8u2394723947 $%$%#$%#$%#^#%^
  68. Hello, world
  69. , abcdefg adsdsfdf
  70. 8u2394723947 $%$%#$%#$%#^#%^
  71. int(129)
  72. -- After seeking position to 13 --
  73. , abcdefg adsdsfdf
  74. 8u2394723947 $%$%#$%#$%#^#%^
  75. Hello, world
  76. , abcdefg adsdsfdf
  77. 8u2394723947 $%$%#$%#$%#^#%^
  78. int(119)
  79. -- After seeking position to 14 --
  80. abcdefg adsdsfdf
  81. 8u2394723947 $%$%#$%#$%#^#%^
  82. Hello, world
  83. , abcdefg adsdsfdf
  84. 8u2394723947 $%$%#$%#$%#^#%^
  85. int(118)
  86. -- After seeking position to 23 --
  87. adsdsfdf
  88. 8u2394723947 $%$%#$%#$%#^#%^
  89. Hello, world
  90. , abcdefg adsdsfdf
  91. 8u2394723947 $%$%#$%#$%#^#%^
  92. int(109)
  93. -- After seeking position to 34 --
  94. 2394723947 $%$%#$%#$%#^#%^
  95. Hello, world
  96. , abcdefg adsdsfdf
  97. 8u2394723947 $%$%#$%#$%#^#%^
  98. int(98)
  99. -- After seeking position to 1000 --
  100. int(0)
  101. *** Done ***