PHP file_exists() 関数

定義と使用方法

file_exists() 関数はファイルやディレクトリが存在するかどうかをチェックします。

指定されたファイルやディレクトリが存在する場合に true を返し、存在しない場合に false を返します。

構文

file_exists(path)
引数 説明
path 必須。チェックするパスを指定します。

<?php
echo file_exists("test.txt");
?>

出力:

1