In the previous article "php file operation: how to obtain the time attribute (information) of the file", we learned that we can use the built-in functions filectime(), filemtime, fileatime() to obtain separate files Three time attributes: creation time, modification time and last access time. Interested friends can learn about it~
The main content of this article is to understand the file size, file type and file/directory permissions method of obtaining. Let’s give you a detailed introduction to how to obtain it.
1. Get the size of the file
You can use thefilesize($filename)
function to return the specified file$filename
the size of. Returns the file size in bytes on success or FALSE on failure.
The output result is:
2. Get the file type
You can usefiletype ($filename)
The function returns the type of the specified file or directory$filename
. If successful, one of the following 7 possible values will be returned:
fifo
{$filename} 文件的类型为:".filetype($filename); $filename = "D:/demo/img"; echo "
{$filename} 文件的类型为:".filetype($filename); ?>
The output result is:
3. Obtain file permissionsYou can use
fileperms ($filename)The function returns the permissions of the file or directory$filename
. If successful, the permissions are returned as a number. On failure, returns FALSE.
Copy after login
The output result is:# Description: The number representing permissions has three possible values. To set multiple permissions, you can use the following numbers. Total:
1 = Execute permission
#2 = Write permission
4 = Read permission
PHP Chinese website platform has a lot of video teaching resources. Welcome everyone to learn "
PHP Video TutorialThe above is the detailed content of How to quickly know the size, type and permissions of the file in php file operations. For more information, please follow other related articles on the PHP Chinese website!
Related labels:
source:php.cn
Previous article:How to exit the script program using PHP functions
Next article:PHP file operation returns the location information of the file (absolute address)
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2023-04-26 17:59:18
-
2023-04-26 17:47:48
-
2023-04-26 17:41:42
-
2023-04-26 17:37:05
-
2023-04-26 17:31:25
-
2023-04-26 17:27:32
-
2023-04-25 19:57:58
-
2023-04-25 19:53:11
-
2023-04-25 19:49:11
-
2023-04-25 19:41:54
Latest Issues
PHP trim unicode spaces
I'm trying to trim unicode spaces such as this character and I was able to do it using thi...
From 2023-11-13 08:49:45
0
2
398
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
-
-
-
JAVA Beginner's Video Tutorial
2365833
-
-
Latest Downloads
More>
-
-
-
-
-
-
-
-
-
About us
Disclaimer
Sitemap
-
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!