问题:代码
<?php $file = fopen("css.css","r"); var_dump(stat($file)); fclose($file); ?>
执行结果: PHP Warning: stat(): stat failed for Resource id #5 修改:
<?php $file = fopen("css.css","r"); var_dump(fstat($file)); fclose($file); ?>
结果: array(26) { [0]=> int(64768) [1]=> int(15996065) [2]=> int(33206) [3]=> int(1) [4]=> int(48) [5]=> int(48) [6]=> int(0) [7]=> int(1282) [8]=> int(1403685503) [9]=> int(1403169630) [10]=> int(1403840670) [11]=> int(4096) [12]=> int(8) ["dev"]=> int(64768) ["ino"]=> int(15996065) ["mode"]=> int(33206) ["nlink"]=> int(1) ["uid"]=> int(48) ["gid"]=> int(48) ["rdev"]=> int(0) ["size"]=> int(1282) ["atime"]=> int(1403685503) ["mtime"]=> int(1403169630) ["ctime"]=> int(1403840670) ["blksize"]=> int(4096) ["blocks"]=> int(8) }
分析原因:fopen和fstat搭配,当然用stat也行,就直接用stat("/path/to/file")不需要close啦