龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

file_exists php中检测文件是否存在的代码

时间:2014-09-14 16:11来源:网络整理 作者:网络 点击:
分享到:
php中检测文件是否存在的代码 [代码片段(16行)]
<?php
$fn = "/home/w3m/public_html/somefile.txt";

if (!file_exists($fn)) {
    die("File $fn does not exist");
}

$fp = @fopen ($fn, 'a')
  or die ("Cannot open $fn for append access");

// Add data to the file
fputs ($fp, "http://www.w3mentor.com/\n");

@fclose ($fp);
?>

精彩图集

赞助商链接