● 獲取文件屬性 我說幾個常見的函數(shù): 獲取最近修改時間: <?php $file = 'test.txt'; echo date('r', filemtime($file)); ?> 返回的說unix的時間戳,這在緩存技術常用. 相關的還有獲取上次被訪問的時間fileatime(),filectime()當文件的權限,所有者,所有組或其它 inode 中的元數(shù)據(jù)被更新時間,fileowner()函數(shù)返回文件所有者 $owner = posix_getpwuid(fileowner($file)); (非window系統(tǒng)),ileperms()獲取文件的權限, <?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'; ?> 獲取文件的全部信息有個返回數(shù)組的函數(shù)stat()函數(shù): <?php $file = 'dirlist.php'; $perms = stat($file); var_dump($perms); ?> 那個鍵對應什么可以查閱詳細資料,此處不再展開. 本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/fkedwgwy/archive/2008/06/04/2511639.aspx
發(fā)表評論