php测试文件-PHP Tutorial-php.cn">
Home > Backend Development > PHP Tutorial > php测试文件

php测试文件

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:23:08
Original
960 people have browsed it

PHP_File文件操作简单常用函数

php测试文件


header("Content-type:text/html;charest=utf-8");
$fileDir='Upload/File/content.txt';
echo '文件路径:'.$fileDir.'
';

echo '路径目录|dirname():'.dirname($fileDir).'
';

echo '路径文件名|basename():'.basename($fileDir).'
';

echo '文件类型|filetype():'.filetype($fileDir).'
';

echo '文件大小|filesize():'.filesize($fileDir).'
';

echo '文件修改时间|filemtime():'.filemtime($fileDir).'
';

echo '
';

echo '绝对路径|realpath():'.realpath($fileDir).'
';

echo '以数组形式返回路径信息|pathinfo():
';

print_r(pathinfo($fileDir));echo '
';

echo '
';

echo '复制并重命名文件|rename(url01,url02):返回'.copy($fileDir,'./Upload/renameContent.txt').'
';

echo '复制文件|copy(url01,url02):返回'.copy($fileDir,'./Upload/copyContent.txt').'
';

echo '删除文件|unlink(url):返回'.@unlink('./Upload/unlinkContent.txt').'
';

echo '
';

echo '将文件信息以字符串形式读取出来|file_get_contents(url):
';

echo file_get_contents($fileDir).'
';

$putContent='hello word!';
echo '将字符串写入文件,文件不存在自动创建,目录必须存在,|file_put_contents(url,str)返回文件大小:';
echo file_put_contents('./Upload/file_put_contents.txt',$putContent).'
';

?>

 

php返回结果

文件路径:Upload/File/content.txt
路径目录|dirname():Upload/File
路径文件名|basename():content.txt
文件类型|filetype():file
文件大小|filesize():27
文件修改时间|filemtime():1411488282

绝对路径|realpath():D:\Kuaipan\www\TestPhp\Upload\File\content.txt
以数组形式返回路径信息|pathinfo():
Array ( [dirname] => Upload/File [basename] => content.txt [extension] => txt [filename] => content )

复制并重命名文件|rename(url01,url02):返回1
复制文件|copy(url01,url02):返回1
删除文件|unlink(url):返回

将文件信息以字符串形式读取出来|file_get_contents(url):
hello word! bad word!!!
将字符串写入文件,文件不存在自动创建,目录必须存在,|file_put_contents(url,str)返回文件大小:11

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template