新聞中心
PHP獲取文件屬性可以用到多種函數(shù),來實現(xiàn)我們對文件各種不同信息的獲取需求。在這里我們就簡單的介紹了這些獲取方式的實現(xiàn)方法。#t#

創(chuàng)新互聯(lián)公司專注于永昌企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站設(shè)計,電子商務(wù)商城網(wǎng)站建設(shè)。永昌網(wǎng)站建設(shè)公司,為永昌等地區(qū)提供建站服務(wù)。全流程專業(yè)公司,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)
PHP獲取文件屬性之獲取最近修改時間:
- < ?php
- $file = 'test.txt';
- echo date('r',
filemtime($file));- ?>
返回的說unix的時間戳,這在緩存技術(shù)常用.
相關(guān)PHP獲取文件屬性的還有獲取上次被訪問的時間fileatime(),filectime()當(dāng)文件的權(quán)限,所有者,所有組或其它 inode 中的元數(shù)據(jù)被更新時間,fileowner()函數(shù)返回文件所有者
$owner = posix_getpwuid(fileowner($file));
(非window系統(tǒng)),ileperms()獲取文件的權(quán)限,
- < ?php
- $file = 'dirlist.php';
- $perms = substr(sprintf
('%o', fileperms($file))
, -4);- echo $perms;
- ?>
filesize()返回文件大小的字節(jié)數(shù):
- < ?php
- // 輸出類似:somefile.txt:
1024 bytes- $filename = 'somefile.txt';
- echo $filename . ': '
. filesize($filename) . ' bytes';- ?>
PHP獲取文件屬性的全部信息有個返回數(shù)組的函數(shù)stat()函數(shù):
- < ?php
- $file = 'dirlist.php';
- $perms = stat($file);
- var_dump($perms);
- ?>
網(wǎng)頁題目:簡單介紹PHP獲取文件屬性方法
文章位置:http://www.5511xx.com/article/dheojdj.html


咨詢
建站咨詢
