1--TEST-- 2Test file function : variation - test various endings of a file 3--CREDITS-- 4Dave Kelsey <d_kelsey@uk.ibm.com> 5--FILE-- 6<?php 7echo "*** Testing file() : variation ***\n"; 8$testfile = __DIR__."/fileVar9.txt"; 9 10$contents = array( 11 "File ends on a single character\na", 12 "File ends on a new line\n", 13 "File ends on multiple newlines\n\n\n\n", 14 "File has\n\nmultiple lines and newlines\n\n", 15 "File has\r\nmultiple crlfs\n\r\n" 16 ); 17 18foreach ($contents as $content) { 19 $h = fopen($testfile, "w"); 20 fwrite($h, $content); 21 fclose($h); 22 var_dump(file($testfile)); 23 unlink($testfile); 24} 25 26echo "\n*** Done ***\n"; 27?> 28--CLEAN-- 29<?php 30$testfile = __DIR__."/fileVar9.txt"; 31@unlink($testfile); 32?> 33--EXPECT-- 34*** Testing file() : variation *** 35array(2) { 36 [0]=> 37 string(32) "File ends on a single character 38" 39 [1]=> 40 string(1) "a" 41} 42array(1) { 43 [0]=> 44 string(24) "File ends on a new line 45" 46} 47array(4) { 48 [0]=> 49 string(31) "File ends on multiple newlines 50" 51 [1]=> 52 string(1) " 53" 54 [2]=> 55 string(1) " 56" 57 [3]=> 58 string(1) " 59" 60} 61array(4) { 62 [0]=> 63 string(9) "File has 64" 65 [1]=> 66 string(1) " 67" 68 [2]=> 69 string(28) "multiple lines and newlines 70" 71 [3]=> 72 string(1) " 73" 74} 75array(3) { 76 [0]=> 77 string(10) "File has 78" 79 [1]=> 80 string(15) "multiple crlfs 81" 82 [2]=> 83 string(2) " 84" 85} 86 87*** Done *** 88