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

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and examples of PHP is_writable() function

PHP Filesystem 参考手册

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 参考手册