1--TEST-- 2Test is_executable() function: usage variations - diff. path notations 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) == 'WIN') { 6 die('skip not for windows'); 7} 8?> 9--FILE-- 10<?php 11/* Prototype: bool is_executable ( string $filename ); 12 Description: Tells whether the filename is executable 13*/ 14 15/* test is_executable() with file having different filepath notation */ 16 17require dirname(__FILE__).'/file.inc'; 18echo "*** Testing is_executable(): usage variations ***\n"; 19 20$file_path = dirname(__FILE__); 21mkdir("$file_path/is_executable_variation1"); 22 23// create a new temporary file 24$fp = fopen("$file_path/is_executable_variation1/bar.tmp", "w"); 25fclose($fp); 26 27/* array of files checked to see if they are executable files 28 using is_executable() function */ 29$files_arr = array( 30 "$file_path/is_executable_variation1/bar.tmp", 31 32 /* Testing a file with trailing slash */ 33 "$file_path/is_executable_variation1/bar.tmp/", 34 35 /* Testing file with double slashes */ 36 "$file_path/is_executable_variation1//bar.tmp", 37 "$file_path/is_executable_variation1/*.tmp", 38 "$file_path/is_executable_variation1/b*.tmp", 39 40 /* Testing Binary safe */ 41 "$file_path/is_executable_variation1".chr(0)."bar.temp", 42 "$file_path".chr(0)."is_executable_variation1/bar.temp", 43 "$file_path/is_executable_variation1x000/", 44 45 /* Testing directories */ 46 ".", // current directory, exp: bool(true) 47 "$file_path/is_executable_variation1" // temp directory, exp: bool(true) 48); 49$counter = 1; 50/* loop through to test each element in the above array 51 is an executable file */ 52foreach($files_arr as $file) { 53 echo "-- Iteration $counter --\n"; 54 var_dump( is_executable($file) ); 55 $counter++; 56 clearstatcache(); 57} 58 59echo "Done\n"; 60?> 61--CLEAN-- 62<?php 63unlink(dirname(__FILE__)."/is_executable_variation1/bar.tmp"); 64rmdir(dirname(__FILE__)."/is_executable_variation1/"); 65?> 66--EXPECTF-- 67*** Testing is_executable(): usage variations *** 68-- Iteration 1 -- 69bool(false) 70-- Iteration 2 -- 71bool(false) 72-- Iteration 3 -- 73bool(false) 74-- Iteration 4 -- 75bool(false) 76-- Iteration 5 -- 77bool(false) 78-- Iteration 6 -- 79 80Warning: is_executable() expects parameter 1 to be a valid path, string given in %s on line %d 81NULL 82-- Iteration 7 -- 83 84Warning: is_executable() expects parameter 1 to be a valid path, string given in %s on line %d 85NULL 86-- Iteration 8 -- 87bool(false) 88-- Iteration 9 -- 89bool(true) 90-- Iteration 10 -- 91bool(true) 92Done 93