1--TEST-- 2Test copy() function: usage variations - wildcard chars in source 3--FILE-- 4<?php 5/* Prototype: bool copy ( string $source, string $dest ); 6 Description: Makes a copy of the file source to dest. 7 Returns TRUE on success or FALSE on failure. 8*/ 9 10/* Test copy(): Trying to copy the source file which is given with the combination of wild-card chars */ 11 12$file_path = dirname(__FILE__); 13 14echo "*** Test copy() function: With source file names containing wild-card chars ***\n"; 15$src_file = $file_path."/copy_variation17.tmp"; 16$file_handle = fopen($src_file, "w"); 17fwrite($file_handle, str_repeat(b"Hello2world...\n", 100)); 18fclose($file_handle); 19 20$dir = $file_path."/copy_variation17"; 21mkdir($dir); 22 23$src_file_names = array( 24 $file_path."/copy_variation17.tmp", //without wild-card char 25 $file_path."/copy*17.tmp", 26 $file_path."/*_variation17.tmp", 27 $file_path."/copy_variation*.tmp", 28 $file_path."/*.tmp" 29); 30 31$dest_file_name = $dir."/copy_copy_variation17.tmp"; 32 33$count = 1; 34foreach($src_file_names as $src_file_name) { 35 var_dump( copy($src_file_name, $dest_file_name) ); 36 var_dump( file_exists($dest_file_name) ); 37 38 if( file_exists($dest_file_name) ) { 39 var_dump( filesize($dest_file_name) ); //size of destination 40 unlink($dest_file_name); 41 } 42 43 $count++; 44} 45 46echo "*** Done ***\n"; 47?> 48 49--CLEAN-- 50<?php 51unlink(dirname(__FILE__)."/copy_variation17.tmp"); 52rmdir(dirname(__FILE__)."/copy_variation17"); 53?> 54 55--EXPECTF-- 56*** Test copy() function: With source file names containing wild-card chars *** 57bool(true) 58bool(true) 59int(1500) 60 61Warning: copy(%s): %s 62bool(false) 63bool(false) 64 65Warning: copy(%s): %s 66bool(false) 67bool(false) 68 69Warning: copy(%s): %s 70bool(false) 71bool(false) 72 73Warning: copy(%s): %s 74bool(false) 75bool(false) 76*** Done *** 77