php获得文件的属性
2015-08-14 16:50
525 查看
PHP获取文件属性可以用到多种函数,来实现我们对文件各种不同信息的获取需求。在这里我们就简单的介绍了这些获取方式的实现方法。
详细解读PHP获取远程图片技巧
详细介绍PHP读取目录函数
如何运用相关函数实现PHP读取文件
PHP写入文件实现技巧分享
技巧分享 PHP删除复制文件
PHP获取文件属性之获取最近修改时间:
< ?php
$file = 'test.txt';
echo date('r',
filemtime($file));
?>
返回的说unix的时间戳,这在缓存技术常用.
相关PHP获取文件属性的还有获取上次被访问的时间fileatime(),filectime()当文件的权限,所有者,所有组或其它 inode 中的元数据被更新时间,fileowner()函数返回文件所有者
$owner = posix_getpwuid(fileowner($file));
(非window系统),ileperms()获取文件的权限,
< ?php
$file = 'dirlist.php';
$perms = substr(sprintf
('%o', fileperms($file))
, -4);
echo $perms;
?>
filesize()返回文件大小的字节数:
< ?php
// 输出类似:somefile.txt:
1024 bytes
$filename = 'somefile.txt';
echo $filename . ': '
. filesize($filename) . ' bytes';
?>
PHP获取文件属性的全部信息有个返回数组的函数stat()函数:
< ?php
$file = 'dirlist.php';
$perms = stat($file);
var_dump($perms);
?>
详细解读PHP获取远程图片技巧
详细介绍PHP读取目录函数
如何运用相关函数实现PHP读取文件
PHP写入文件实现技巧分享
技巧分享 PHP删除复制文件
PHP获取文件属性之获取最近修改时间:
< ?php
$file = 'test.txt';
echo date('r',
filemtime($file));
?>
返回的说unix的时间戳,这在缓存技术常用.
相关PHP获取文件属性的还有获取上次被访问的时间fileatime(),filectime()当文件的权限,所有者,所有组或其它 inode 中的元数据被更新时间,fileowner()函数返回文件所有者
$owner = posix_getpwuid(fileowner($file));
(非window系统),ileperms()获取文件的权限,
< ?php
$file = 'dirlist.php';
$perms = substr(sprintf
('%o', fileperms($file))
, -4);
echo $perms;
?>
filesize()返回文件大小的字节数:
< ?php
// 输出类似:somefile.txt:
1024 bytes
$filename = 'somefile.txt';
echo $filename . ': '
. filesize($filename) . ' bytes';
?>
PHP获取文件属性的全部信息有个返回数组的函数stat()函数:
< ?php
$file = 'dirlist.php';
$perms = stat($file);
var_dump($perms);
?>
相关文章推荐
- PHP数组处理函数的使用array_map(三)
- webservice SoapHeader 验证
- PHP判断字符串的包含
- PHP的内存泄露问题与垃圾回收
- php 对象接口
- ubuntu phpstorm 安装xdebuger
- ***PHP 去除换行符
- PHP数据库操作总结
- 详解yii用户登录体系
- php与html简单的json交互示例
- php实现双色球的生成
- PHP 过滤 及 字符转换 函数
- PHP中session和cookie的区别
- php的数据类型和变量的作用域
- php相册功能实现(包含php图片上传,后台管理,浏览和删除)教程例子
- PHP数组处理函数的使用array_reduce(二)
- Ubuntu之Jenkins的SMTP TLS邮箱设置
- Session
- php生成图片缩略图的类方法
- PHP数据类型转换的一些坑