fflush_variation1-win32.phpt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. --TEST--
  2. Test fflush() function: usage variations - files in different modes
  3. --SKIPIF--
  4. <?php
  5. if( substr(PHP_OS, 0, 3) != "WIN" )
  6. die("skip.. only for Windows");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype: bool fflush ( resource $handle );
  11. Description: Flushes the output to a file
  12. */
  13. /* test fflush() with handle to the files opened in different modes */
  14. $file_path = dirname(__FILE__);
  15. require $file_path.'/file.inc';
  16. echo "*** Testing fflush(): with various types of files ***\n";
  17. $file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric");
  18. $file_modes = array("w", "wb", "wt", "w+", "w+b", "w+t",
  19. "a", "ab", "at", "a+","a+b", "a+t",
  20. "x", "xb", "xt", "x+", "x+b", "x+t");
  21. $file_name = "$file_path/fflush_variation1.tmp";
  22. $count = 1;
  23. foreach( $file_types as $type ) {
  24. echo "-- Iteration $count with file containing $type Data--\n";
  25. foreach( $file_modes as $mode ) {
  26. echo "-- File opened in $mode mode --\n";
  27. // creating the file except for x mode
  28. if( substr($mode, 0, 1) != "x" ) {
  29. $file_handle = fopen($file_name, "w");
  30. if($file_handle == false)
  31. exit("Error:failed to open file $file_name");
  32. // filling the file some data if mode is append mode
  33. if( substr($mode, 0, 1) == "a")
  34. fill_file($file_handle, $type, 10);
  35. fclose($file_handle);
  36. }
  37. // opening the file in different modes
  38. $file_handle = fopen($file_name, $mode);
  39. if($file_handle == false)
  40. exit("Error:failed to open file $file_name");
  41. // writing data to the file
  42. var_dump( fill_file($file_handle, $type, 50) );
  43. var_dump( fflush($file_handle) );
  44. fclose($file_handle);
  45. // reading the contents of the file after flushing
  46. var_dump( readfile($file_name) );
  47. unlink($file_name);
  48. }
  49. $count++;
  50. }
  51. echo "\n*** Done ***";
  52. ?>
  53. --EXPECTF--
  54. *** Testing fflush(): with various types of files ***
  55. -- Iteration 1 with file containing empty Data--
  56. -- File opened in w mode --
  57. bool(true)
  58. bool(true)
  59. int(0)
  60. -- File opened in wb mode --
  61. bool(true)
  62. bool(true)
  63. int(0)
  64. -- File opened in wt mode --
  65. bool(true)
  66. bool(true)
  67. int(0)
  68. -- File opened in w+ mode --
  69. bool(true)
  70. bool(true)
  71. int(0)
  72. -- File opened in w+b mode --
  73. bool(true)
  74. bool(true)
  75. int(0)
  76. -- File opened in w+t mode --
  77. bool(true)
  78. bool(true)
  79. int(0)
  80. -- File opened in a mode --
  81. bool(true)
  82. bool(true)
  83. int(0)
  84. -- File opened in ab mode --
  85. bool(true)
  86. bool(true)
  87. int(0)
  88. -- File opened in at mode --
  89. bool(true)
  90. bool(true)
  91. int(0)
  92. -- File opened in a+ mode --
  93. bool(true)
  94. bool(true)
  95. int(0)
  96. -- File opened in a+b mode --
  97. bool(true)
  98. bool(true)
  99. int(0)
  100. -- File opened in a+t mode --
  101. bool(true)
  102. bool(true)
  103. int(0)
  104. -- File opened in x mode --
  105. bool(true)
  106. bool(true)
  107. int(0)
  108. -- File opened in xb mode --
  109. bool(true)
  110. bool(true)
  111. int(0)
  112. -- File opened in xt mode --
  113. bool(true)
  114. bool(true)
  115. int(0)
  116. -- File opened in x+ mode --
  117. bool(true)
  118. bool(true)
  119. int(0)
  120. -- File opened in x+b mode --
  121. bool(true)
  122. bool(true)
  123. int(0)
  124. -- File opened in x+t mode --
  125. bool(true)
  126. bool(true)
  127. int(0)
  128. -- Iteration 2 with file containing numeric Data--
  129. -- File opened in w mode --
  130. bool(true)
  131. bool(true)
  132. 22222222222222222222222222222222222222222222222222int(50)
  133. -- File opened in wb mode --
  134. bool(true)
  135. bool(true)
  136. 22222222222222222222222222222222222222222222222222int(50)
  137. -- File opened in wt mode --
  138. bool(true)
  139. bool(true)
  140. 22222222222222222222222222222222222222222222222222int(50)
  141. -- File opened in w+ mode --
  142. bool(true)
  143. bool(true)
  144. 22222222222222222222222222222222222222222222222222int(50)
  145. -- File opened in w+b mode --
  146. bool(true)
  147. bool(true)
  148. 22222222222222222222222222222222222222222222222222int(50)
  149. -- File opened in w+t mode --
  150. bool(true)
  151. bool(true)
  152. 22222222222222222222222222222222222222222222222222int(50)
  153. -- File opened in a mode --
  154. bool(true)
  155. bool(true)
  156. 222222222222222222222222222222222222222222222222222222222222int(60)
  157. -- File opened in ab mode --
  158. bool(true)
  159. bool(true)
  160. 222222222222222222222222222222222222222222222222222222222222int(60)
  161. -- File opened in at mode --
  162. bool(true)
  163. bool(true)
  164. 222222222222222222222222222222222222222222222222222222222222int(60)
  165. -- File opened in a+ mode --
  166. bool(true)
  167. bool(true)
  168. 222222222222222222222222222222222222222222222222222222222222int(60)
  169. -- File opened in a+b mode --
  170. bool(true)
  171. bool(true)
  172. 222222222222222222222222222222222222222222222222222222222222int(60)
  173. -- File opened in a+t mode --
  174. bool(true)
  175. bool(true)
  176. 222222222222222222222222222222222222222222222222222222222222int(60)
  177. -- File opened in x mode --
  178. bool(true)
  179. bool(true)
  180. 22222222222222222222222222222222222222222222222222int(50)
  181. -- File opened in xb mode --
  182. bool(true)
  183. bool(true)
  184. 22222222222222222222222222222222222222222222222222int(50)
  185. -- File opened in xt mode --
  186. bool(true)
  187. bool(true)
  188. 22222222222222222222222222222222222222222222222222int(50)
  189. -- File opened in x+ mode --
  190. bool(true)
  191. bool(true)
  192. 22222222222222222222222222222222222222222222222222int(50)
  193. -- File opened in x+b mode --
  194. bool(true)
  195. bool(true)
  196. 22222222222222222222222222222222222222222222222222int(50)
  197. -- File opened in x+t mode --
  198. bool(true)
  199. bool(true)
  200. 22222222222222222222222222222222222222222222222222int(50)
  201. -- Iteration 3 with file containing text Data--
  202. -- File opened in w mode --
  203. bool(true)
  204. bool(true)
  205. text text text text text text text text text text int(50)
  206. -- File opened in wb mode --
  207. bool(true)
  208. bool(true)
  209. text text text text text text text text text text int(50)
  210. -- File opened in wt mode --
  211. bool(true)
  212. bool(true)
  213. text text text text text text text text text text int(50)
  214. -- File opened in w+ mode --
  215. bool(true)
  216. bool(true)
  217. text text text text text text text text text text int(50)
  218. -- File opened in w+b mode --
  219. bool(true)
  220. bool(true)
  221. text text text text text text text text text text int(50)
  222. -- File opened in w+t mode --
  223. bool(true)
  224. bool(true)
  225. text text text text text text text text text text int(50)
  226. -- File opened in a mode --
  227. bool(true)
  228. bool(true)
  229. text text text text text text text text text text text text int(60)
  230. -- File opened in ab mode --
  231. bool(true)
  232. bool(true)
  233. text text text text text text text text text text text text int(60)
  234. -- File opened in at mode --
  235. bool(true)
  236. bool(true)
  237. text text text text text text text text text text text text int(60)
  238. -- File opened in a+ mode --
  239. bool(true)
  240. bool(true)
  241. text text text text text text text text text text text text int(60)
  242. -- File opened in a+b mode --
  243. bool(true)
  244. bool(true)
  245. text text text text text text text text text text text text int(60)
  246. -- File opened in a+t mode --
  247. bool(true)
  248. bool(true)
  249. text text text text text text text text text text text text int(60)
  250. -- File opened in x mode --
  251. bool(true)
  252. bool(true)
  253. text text text text text text text text text text int(50)
  254. -- File opened in xb mode --
  255. bool(true)
  256. bool(true)
  257. text text text text text text text text text text int(50)
  258. -- File opened in xt mode --
  259. bool(true)
  260. bool(true)
  261. text text text text text text text text text text int(50)
  262. -- File opened in x+ mode --
  263. bool(true)
  264. bool(true)
  265. text text text text text text text text text text int(50)
  266. -- File opened in x+b mode --
  267. bool(true)
  268. bool(true)
  269. text text text text text text text text text text int(50)
  270. -- File opened in x+t mode --
  271. bool(true)
  272. bool(true)
  273. text text text text text text text text text text int(50)
  274. -- Iteration 4 with file containing text_with_new_line Data--
  275. -- File opened in w mode --
  276. bool(true)
  277. bool(true)
  278. line
  279. line of text
  280. line
  281. line of text
  282. line
  283. line of tint(50)
  284. -- File opened in wb mode --
  285. bool(true)
  286. bool(true)
  287. line
  288. line of text
  289. line
  290. line of text
  291. line
  292. line of tint(50)
  293. -- File opened in wt mode --
  294. bool(true)
  295. bool(true)
  296. line
  297. line of text
  298. line
  299. line of text
  300. line
  301. line of tint(55)
  302. -- File opened in w+ mode --
  303. bool(true)
  304. bool(true)
  305. line
  306. line of text
  307. line
  308. line of text
  309. line
  310. line of tint(50)
  311. -- File opened in w+b mode --
  312. bool(true)
  313. bool(true)
  314. line
  315. line of text
  316. line
  317. line of text
  318. line
  319. line of tint(50)
  320. -- File opened in w+t mode --
  321. bool(true)
  322. bool(true)
  323. line
  324. line of text
  325. line
  326. line of text
  327. line
  328. line of tint(55)
  329. -- File opened in a mode --
  330. bool(true)
  331. bool(true)
  332. line
  333. line line
  334. line of text
  335. line
  336. line of text
  337. line
  338. line of tint(60)
  339. -- File opened in ab mode --
  340. bool(true)
  341. bool(true)
  342. line
  343. line line
  344. line of text
  345. line
  346. line of text
  347. line
  348. line of tint(60)
  349. -- File opened in at mode --
  350. bool(true)
  351. bool(true)
  352. line
  353. line line
  354. line of text
  355. line
  356. line of text
  357. line
  358. line of tint(65)
  359. -- File opened in a+ mode --
  360. bool(true)
  361. bool(true)
  362. line
  363. line line
  364. line of text
  365. line
  366. line of text
  367. line
  368. line of tint(60)
  369. -- File opened in a+b mode --
  370. bool(true)
  371. bool(true)
  372. line
  373. line line
  374. line of text
  375. line
  376. line of text
  377. line
  378. line of tint(60)
  379. -- File opened in a+t mode --
  380. bool(true)
  381. bool(true)
  382. line
  383. line line
  384. line of text
  385. line
  386. line of text
  387. line
  388. line of tint(65)
  389. -- File opened in x mode --
  390. bool(true)
  391. bool(true)
  392. line
  393. line of text
  394. line
  395. line of text
  396. line
  397. line of tint(50)
  398. -- File opened in xb mode --
  399. bool(true)
  400. bool(true)
  401. line
  402. line of text
  403. line
  404. line of text
  405. line
  406. line of tint(50)
  407. -- File opened in xt mode --
  408. bool(true)
  409. bool(true)
  410. line
  411. line of text
  412. line
  413. line of text
  414. line
  415. line of tint(55)
  416. -- File opened in x+ mode --
  417. bool(true)
  418. bool(true)
  419. line
  420. line of text
  421. line
  422. line of text
  423. line
  424. line of tint(50)
  425. -- File opened in x+b mode --
  426. bool(true)
  427. bool(true)
  428. line
  429. line of text
  430. line
  431. line of text
  432. line
  433. line of tint(50)
  434. -- File opened in x+t mode --
  435. bool(true)
  436. bool(true)
  437. line
  438. line of text
  439. line
  440. line of text
  441. line
  442. line of tint(55)
  443. -- Iteration 5 with file containing alphanumeric Data--
  444. -- File opened in w mode --
  445. bool(true)
  446. bool(true)
  447. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  448. -- File opened in wb mode --
  449. bool(true)
  450. bool(true)
  451. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  452. -- File opened in wt mode --
  453. bool(true)
  454. bool(true)
  455. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  456. -- File opened in w+ mode --
  457. bool(true)
  458. bool(true)
  459. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  460. -- File opened in w+b mode --
  461. bool(true)
  462. bool(true)
  463. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  464. -- File opened in w+t mode --
  465. bool(true)
  466. bool(true)
  467. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  468. -- File opened in a mode --
  469. bool(true)
  470. bool(true)
  471. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
  472. -- File opened in ab mode --
  473. bool(true)
  474. bool(true)
  475. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
  476. -- File opened in at mode --
  477. bool(true)
  478. bool(true)
  479. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
  480. -- File opened in a+ mode --
  481. bool(true)
  482. bool(true)
  483. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
  484. -- File opened in a+b mode --
  485. bool(true)
  486. bool(true)
  487. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
  488. -- File opened in a+t mode --
  489. bool(true)
  490. bool(true)
  491. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
  492. -- File opened in x mode --
  493. bool(true)
  494. bool(true)
  495. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  496. -- File opened in xb mode --
  497. bool(true)
  498. bool(true)
  499. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  500. -- File opened in xt mode --
  501. bool(true)
  502. bool(true)
  503. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  504. -- File opened in x+ mode --
  505. bool(true)
  506. bool(true)
  507. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  508. -- File opened in x+b mode --
  509. bool(true)
  510. bool(true)
  511. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  512. -- File opened in x+t mode --
  513. bool(true)
  514. bool(true)
  515. ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
  516. *** Done ***