1--TEST-- 2Test is_writable() and its alias is_writeable() function: usage variations - invalid file names 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) != 'WIN') { 6 // Skip if being run by root (files are always readable, writeable and executable) 7 $filename = dirname(__FILE__)."/is_writable_root_check.tmp"; 8 $fp = fopen($filename, 'w'); 9 fclose($fp); 10 if(fileowner($filename) == 0) { 11 unlink ($filename); 12 die('skip cannot be run as root'); 13 } 14 unlink($filename); 15} 16?> 17--FILE-- 18<?php 19/* Prototype: bool is_writable ( string $filename ); 20 Description: Tells whether the filename is writable. 21 22 is_writeable() is an alias of is_writable() 23*/ 24 25/* test is_writable() & is_writeable() with invalid arguments */ 26 27echo "*** Testing is_writable(): usage variations ***\n"; 28 29echo "\n*** Testing is_writable() with invalid filenames ***\n"; 30$misc_files = array( 31 0, 32 1234, 33 -2.34555, 34 TRUE, 35 FALSE, 36 NULL, 37 " ", 38 @array(), 39 @$file_handle 40); 41/* loop through to test each element in the above array 42 is a writable file */ 43foreach( $misc_files as $misc_file ) { 44 var_dump( is_writable($misc_file) ); 45 var_dump( is_writeable($misc_file) ); 46 clearstatcache(); 47} 48 49echo "Done\n"; 50?> 51--EXPECTF-- 52*** Testing is_writable(): usage variations *** 53 54*** Testing is_writable() with invalid filenames *** 55bool(false) 56bool(false) 57bool(false) 58bool(false) 59bool(false) 60bool(false) 61bool(false) 62bool(false) 63bool(false) 64bool(false) 65bool(false) 66bool(false) 67bool(false) 68bool(false) 69 70Warning: is_writable() expects parameter 1 to be a valid path, array given in %s on line %d 71NULL 72 73Warning: is_writeable() expects parameter 1 to be a valid path, array given in %s on line %d 74NULL 75bool(false) 76bool(false) 77Done 78