<?php
Header (' Content-type:text/html;charset=utf-8 ');
Date_default_timezone_set (' PRC ');
/**
* File information related API
*/
$filename = "./test1.txt";
$filename = "Test";
FileType ($filename): Gets the type of file, returns the type of file
echo ' File type: ', filetype ($filename), ' <br/> ';
FileSize ($filename): Gets the size of the file, returns the bytes
echo ' File size: ', FileSize ($filename), ' <br/> ';
Filectime ($filename): Gets the creation time of the file
Echo ' File creation time: ', Filectime ($filename), ' <br/> ';
Echo ' File creation time is: ', date (' Y year m D Day H:i:s ', Filectime ($filename)), ' <br/> ';
Filemtime ($filename): Modified time of File
echo ' File modification time is: ', date ("Y/m/d h:i:s", Filemtime ($filename)), ' <br/> ';
Fileatime ($filename): Last accessed time for files
The last access time for Echo ' file is: ', date ("Y/m/d h:i:s", Fileatime ($filename)), ' <br/> ';
Echo ' Detect whether the file is readable, writable, executable is_readable (), is_writeable (), is_executable ();
Var_dump (
Is_readable ($filename),
Is_writable ($filename),
Is_writeable ($filename),
Is_executable ($filename)
);
Is_file ($filename): detects if a file is present and the file exists
$filename = './test1.txt ';
$filename = './test2.txt ';
Var_dump (Is_file ($filename));
/**
* PathInfo (): File path Related information
*/
$filename = "./test1.txt";
$pathinfo =pathinfo ($filename);
Print_r ($pathinfo);
/*
Array
(
[DirName] =.
[BaseName] = Test1.txt
[Extension] = txt
[FileName] = Test1
)
*/
echo ' File extension: ', PathInfo ($filename, pathinfo_extension), ' <br/> ';
Echo ' $filename =__file__;
echo $filename;
Echo PathInfo ($filename, Pathinfo_dirname), ' <br/> ';
Echo PathInfo ($filename, Pathinfo_basename), ' <br/> ';
Echo PathInfo ($filename, pathinfo_extension), ' <br/> ';
Echo PathInfo ($filename, Pathinfo_filename), ' <br/> ';
BaseName (): Returns the file name portion of the path
Echo basename ($filename), ' <br/> ';
Echo basename ($filename, '. php '), ' <br/> '; The file name part of the return path does not contain the. php suffix
DirName (): Returns the path part of the file name
echo dirname ($filename), ' <br/> ';
File_exists (): detects whether a file or directory exists
PHP Get file information related basic functions