Return to unlink_basic.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Testing unlink() function : basic functionality 3: --FILE-- 4: <?php 5: /* Prototype : bool unlink ( string $filename [, resource $context] ); 6: Description : Deletes filename 7: */ 8: 9: $file_path = dirname(__FILE__); 10: 11: echo "*** Testing unlink() on a file ***\n"; 12: $filename = "$file_path/unlink_basic.tmp"; // temp file name used here 13: $fp = fopen($filename, "w"); // create file 14: fwrite($fp, "Hello World"); 15: fclose($fp); 16: 17: // delete file 18: var_dump( unlink($filename) ); 19: var_dump( file_exists($filename) ); // confirm file doesnt exist 20: 21: echo "\n*** Testing unlink() : checking second argument ***\n"; 22: // creating a context 23: $context = stream_context_create(); 24: // temp file name used here 25: $filename = "$file_path/unlink_basic.tmp"; 26: $fp = fopen($filename, "w"); // create file 27: fclose($fp); 28: 29: // delete file 30: var_dump( unlink($filename, $context) ); // using $context in second argument 31: var_dump( file_exists($filename) ); // confirm file doesnt exist 32: 33: echo "Done\n"; 34: ?> 35: --EXPECTF-- 36: *** Testing unlink() on a file *** 37: bool(true) 38: bool(false) 39: 40: *** Testing unlink() : checking second argument *** 41: bool(true) 42: bool(false) 43: Done