1--TEST-- 2Test copy() function: usage variations - destination dir access perms 3--SKIPIF-- 4<?php 5if(substr(PHP_OS, 0, 3) == 'WIN') 6 die("skip do not run on Windows"); 7require __DIR__ . '/../skipif_root.inc'; 8?> 9--FILE-- 10<?php 11/* Prototype: bool copy ( string $source, string $dest ); 12 Description: Makes a copy of the file source to dest. 13 Returns TRUE on success or FALSE on failure. 14*/ 15 16/* Test copy(): Trying to create a copy of file in a dir which doesn't have write permissions */ 17 18$file_path = __DIR__; 19 20echo "*** Test copy() function: Trying to create a copy of file in a dir which doesn't have write permissions ***"; 21$file = $file_path."/copy_variation15.tmp"; 22$file_handle = fopen($file, "w"); 23fwrite($file_handle, str_repeat("Hello, world...", 20)); 24fclose($file_handle); 25 26$dir = $file_path."/copy_variation15"; 27mkdir($dir); 28 29$old_perms = fileperms($dir); 30 31chmod($dir, 0555); //dir without write permissions 32 33$dest = $dir."/copy_copy_variation15.tmp"; 34 35var_dump( copy($file, $dir."/copy_copy_variation15.tmp") ); 36var_dump( file_exists($dir."/copy_copy_variation15_dir.tmp") ); 37var_dump( filesize($file) ); //size of source 38 39chmod($dir, $old_perms); 40 41echo "*** Done ***\n"; 42?> 43--CLEAN-- 44<?php 45unlink(__DIR__."/copy_variation15.tmp"); 46rmdir(__DIR__."/copy_variation15"); 47?> 48--EXPECTF-- 49*** Test copy() function: Trying to create a copy of file in a dir which doesn't have write permissions *** 50Warning: copy(%s): %s 51bool(false) 52bool(false) 53int(300) 54*** Done *** 55