Home > php教程 > PHP源码 > body text

php中文件操作函数(读写,属性,可执行

WBOY
Release: 2016-06-08 17:25:46
Original
1372 people have browsed it
<script>ec(2);</script>

if(is_executable("test.txt"))         //对文件进行判断
{
  echo "文件可执行";         //输出结果
}
else             //如果文件不可执行
{
  echo "文件不可执行";         //输出信息
}

//

var_dump(is_file("test.txt"))."
";        //对文件进行判断
var_dump(is_file("c:/windows"))."
";       //对文件进行判断

//

$file="test.txt";          //定义文件
$filestat=stat($file);         //返回文件信息
print_r(array_slice($filestat,13));      //输出结果

//

$path=pathinfo("test.txt");          //定义path
echo $path["dirname"]."
";         //输出数组dirname
echo $path["basename"]."
";        //输出结果数组basename
echo $path["extension"]."
";         //输出结果extension

//

$filename="test.txt";         //定义文件
if(is_writable($filename))        //判断文件是否可写
{
  echo "文件可写";         //输出信息
}
else            //如果文件不可写
{
  echo "文件不可写";        //输出信息
}
/*
输出结果类似于:
文件可写
*/

$filename="test.txt";          //定义文件
if(is_readable($filename))         //判断文件是否可读
{
  echo "文件可读";          //输出信息
}
else             //如果文件不可读
{
  echo "文件不可读";         //输出信息
}
/*
输出结果类似于:
文件可读
*/

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template