1--TEST-- 2Test filetype() function: Variations 3--SKIPIF-- 4<?php 5if (!function_exists("posix_mkfifo")) { 6 die("skip no posix_mkfifo()"); 7} 8?> 9--FILE-- 10<?php 11/* 12Prototype: string filetype ( string $filename ); 13Description: Returns the type of the file. Possible values are fifo, char, 14 dir, block, link, file, and unknown. 15*/ 16 17echo "*** Testing filetype() with various types ***\n"; 18$file_path = __DIR__; 19$file1 = $file_path."/filetype1_variation.tmp"; 20$file2 = $file_path."/filetype2_variation.tmp"; 21$file3 = $file_path."/filetype3_variation.tmp"; 22$link1 = $file_path."/filetype1_variation_link.tmp"; 23$link2 = $file_path."/filetype2_variation_link.tmp"; 24 25fclose( fopen($file1, "w") ); 26fclose( fopen($file2, "w") ); 27 28echo "-- Checking with files --\n"; 29print( filetype($file1) )."\n"; 30print( filetype($file2) )."\n"; 31clearstatcache(); 32 33echo "-- Checking with links: hardlink --\n"; 34link( $file1, $link1); 35print( filetype($link1 ) )."\n"; 36 37echo "-- Checking with links: symlink --\n"; 38symlink( $file2, $link2); 39print( filetype($link2) )."\n"; 40 41unlink($link1); 42unlink($link2); 43unlink($file1); 44unlink($file2); 45 46echo "-- Checking with directory --\n"; 47mkdir("$file_path/filetype_variation"); 48print( filetype("$file_path/filetype_variation") )."\n"; 49rmdir( "$file_path/filetype_variation" ); 50 51echo "-- Checking with fifo --\n"; 52posix_mkfifo( $file3, 0755); 53print( filetype( $file3) )."\n"; 54unlink($file3); 55 56/* Checking with block in file */ 57/* To test this PEAR package should be installed */ 58 59echo "\n*** Done ***\n"; 60?> 61--EXPECT-- 62*** Testing filetype() with various types *** 63-- Checking with files -- 64file 65file 66-- Checking with links: hardlink -- 67file 68-- Checking with links: symlink -- 69link 70-- Checking with directory -- 71dir 72-- Checking with fifo -- 73fifo 74 75*** Done *** 76