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/* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
12   Description: Outputs a file
13*/
14
15/* Variation 2 : Create file
16                 Create soft/hard link to it
17                 Read link using readfile()
18                 Delete file and its link
19*/
20
21// include file.inc
22require("file.inc");
23
24$file_path = dirname(__FILE__);
25
26// temp file used here
27$filename = "$file_path/readfile_variation2.tmp";
28
29// create temp file and insert data into it
30$fp = fopen($filename, "w");
31fill_file($fp, "text_with_new_line", 50);
32fclose($fp);
33
34// temp link name used
35$linkname = "$file_path/readfile_variation2_link.tmp";
36
37/* Checking readfile() operation on soft link */
38echo "*** Testing readfile() on soft link ***\n";
39
40// create soft link to $filename
41var_dump( symlink($filename, $linkname) );
42// readfile() on soft link
43$count = readfile($linkname); // with default args
44echo "\n";
45var_dump($count);
46// delete link
47unlink($linkname);
48
49/* Checking readfile() operation on hard link */
50echo "\n*** Testing readfile() on hard link ***\n";
51// create hard link to $filename
52var_dump( link($filename, $linkname) );
53// readfile() on hard link
54$count = readfile($linkname); // default args
55echo "\n";
56var_dump($count);
57// delete link
58unlink($linkname);
59
60echo "Done\n";
61?>
62--CLEAN--
63<?php
64$file_path = dirname(__FILE__);
65unlink("$file_path/readfile_variation2.tmp");
66?>
67--EXPECTF--
68*** Testing readfile() on soft link ***
69bool(true)
70line
71line of text
72line
73line of text
74line
75line of t
76int(50)
77
78*** Testing readfile() on hard link ***
79bool(true)
80line
81line of text
82line
83line of text
84line
85line of t
86int(50)
87Done
88