目次

PHP:関数使用例:ファイルシステム:file_exists

分類

ファイルシステム

機能

ファイルまたはディレクトリが存在するかどうか調べる

sample

ソース

<html>
<head>
<title>t_file_exist.php</title>
<body>
<?php
$file_name ="/home/hoge/public_html/test/test.txt";
if(file_exists($file_name)){
  echo "ファイル(".$file_name.")あり";
 
}else{
  echo "ファイル(".$file_name.")なし";
}
?>
</body>
</html>

出力結果

ファイル(/home/hoge/public_html/test/test.txt)あり