English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP is_writable() Function Usage and Example

PHP Filesystem Reference Manual

The is_writable() function can check if the specified file is writable. If the file is writable, this function can return true.

Syntax

bool is_writable ( string $filename )

If the filename exists and is writable, this function can return true. The filename parameter can be a directory name, which allows us to also check if the directory is writable.

Online Example

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

Output Result

/PhpProject/php/phptest.txt is writable
PHP Filesystem Reference Manual