1--TEST-- 2Test readfile() function: usage variations - links 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) == 'WIN') { 6 die('skip.. only on Linux'); 7} 8?> 9--FILE-- 10<?php 11/* Variation 2 : Create file 12 Create soft/hard link to it 13 Read link using readfile() 14 Delete file and its link 15*/ 16 17// include file.inc 18require("file.inc"); 19 20$file_path = __DIR__; 21 22// temp file used here 23$filename = "$file_path/readfile_variation2.tmp"; 24 25// create temp file and insert data into it 26$fp = fopen($filename, "w"); 27fill_file($fp, "text_with_new_line", 50); 28fclose($fp); 29 30// temp link name used 31$linkname = "$file_path/readfile_variation2_link.tmp"; 32 33/* Checking readfile() operation on soft link */ 34echo "*** Testing readfile() on soft link ***\n"; 35 36// create soft link to $filename 37var_dump( symlink($filename, $linkname) ); 38// readfile() on soft link 39$count = readfile($linkname); // with default args 40echo "\n"; 41var_dump($count); 42// delete link 43unlink($linkname); 44 45/* Checking readfile() operation on hard link */ 46echo "\n*** Testing readfile() on hard link ***\n"; 47// create hard link to $filename 48var_dump( link($filename, $linkname) ); 49// readfile() on hard link 50$count = readfile($linkname); // default args 51echo "\n"; 52var_dump($count); 53// delete link 54unlink($linkname); 55 56echo "Done\n"; 57?> 58--CLEAN-- 59<?php 60$file_path = __DIR__; 61unlink("$file_path/readfile_variation2.tmp"); 62?> 63--EXPECT-- 64*** Testing readfile() on soft link *** 65bool(true) 66line 67line of text 68line 69line of text 70line 71line of t 72int(50) 73 74*** Testing readfile() on hard link *** 75bool(true) 76line 77line of text 78line 79line of text 80line 81line of t 82int(50) 83Done 84