fflush_variation1-win32-mb.phpt 11 KB

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