PHP File Handling: Examining File Details
Submitted by joken on Friday, January 10, 2014 - 09:34.
In this tutorial, I’m going to show how to get information about the file details. To start in this lesson lets create a new PHP file called “file_detail.php”. And add the following code:
When executing the code above, it will return the size of a file in bytes and all the modification time are all the same. And it looks like as shown below.
Output:
Output:
- <?php
- $testfile = 'hello.txt';
- //this next line are the mdifcation time, and its more than just number
- //filemtime: last modified (changed content). and its the file modifiaction time
- //filectime: last changed (changed content or metadata)or the last change time of the content of metadata
- //fileatime: last accessed (any read/change). it keeps track when a file is last accessed
- ?>
13
01/09/2014 14:37
01/03/2014 02:53
01/09/2014 14:37
Next, on that we can modify those time is using the touch command, so that we can update those into the current time and we can also pass in some additional arguments. But this were going to set it to the current system time and flip all of these time to the current time. and here’s the following code.
- <?php
- $testfile = 'hello.txt';
- //this next line are the mdifcation time, and its more than just number
- //filemtime: last modified (changed content). and its the file modifiaction time
- //filectime: last changed (changed content or metadata)or the last change time of the content of metadata
- //fileatime: last accessed (any read/change). it keeps track when a file is last accessed
- //this next line are the mdifcation time, and its more than just number
- //filemtime: last modified (changed content). and its the file modifiaction time
- //filectime: last changed (changed content or metadata)or the last change time of the content of metadata
- //fileatime: last accessed (any read/change). it keeps track when a file is last accessed
- //in this line of code we're going to get back the file info using pathinfo
- echo $pathinfo['dirname'].'<br/>';// returns the directory name
- echo $pathinfo['basename'].'<br/>';// returns file details
- echo $pathinfo['filename'].'<br/>';// returns file_details.php
- echo $pathinfo['extension'].'<br/>';// returns php
- ?>
16
01/09/2014 14:37
01/03/2014 02:53
01/09/2014 14:37
01/09/2014 14:37
01/03/2014 02:53
01/09/2014 14:37
C:\xampp\htdocs\file
file_detail.php
file_detail
php
Add new comment
- 135 views