• PHP Video Tutorials

PHP - Function is_writable()



The is_writable() function can check whether the specified file is writable. This function can return true if the file is writable.

Syntax

bool is_writable ( string $filename )

This function can return true if the filename exists and is writable. The filename argument may be a directory name that allows us to check if the directory is writable.

Example

<?php
   $file = "/PhpProject/php/phptest.txt";
   if(is_writable($file)) {
       echo ("$file is writable");
   } else {
       echo ("$file is not writable");
   }
?>

Output

/PhpProject/php/phptest.txt is writable
php_function_reference.htm
Advertisements