PHP is_writable() 関数


❮ 完全な PHP ファイルシステム・リファレンス

定義と用法

is_writable() 関数は、指定したファイルが出力可能かどうかをチェックします。

この関数は、ファイルが出力可能な場合は TRUE を返します。

構文

is_writable(file)

パラメータ 説明
file 必須。チェックするファイルを指定する

チップスと注意

注: この関数の結果はキャッシュされます。キャッシュをクリアするには clearstatcache()を使用します。


<?php
$file = "test.txt";
if(is_writable($file))
  {
  echo ("$file is writeable");
  }
else
  {
  echo ("$file is not writeable");
  }
?>

上のコードの出力は次の様になります:

test.txt is writeable

❮ 完全な PHP ファイルシステム・リファレンス