0
0
PHPprogramming~5 mins

File existence and info checks in PHP - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What PHP function checks if a file exists?
The file_exists() function checks if a file or directory exists at the specified path.
Click to reveal answer
beginner
How do you check if a path is a directory in PHP?
Use the is_dir() function to check if the given path is a directory.
Click to reveal answer
beginner
What function returns the size of a file in bytes?
The filesize() function returns the size of a file in bytes.
Click to reveal answer
beginner
How can you check if a file is readable in PHP?
Use the is_readable() function to check if the file can be read.
Click to reveal answer
beginner
What does is_file() check in PHP?
It checks if the given path exists and is a regular file (not a directory).
Click to reveal answer
Which PHP function checks if a file or directory exists?
Afile_exists()
Bis_file()
Cis_dir()
Dfilesize()
What does is_dir() return if the path is a file?
Afalse
Btrue
Cnull
Dthrows error
Which function gives the size of a file in bytes?
Afile_exists()
Bfilesize()
Cis_readable()
Dis_file()
How to check if a file can be read by PHP?
Afile_exists()
Bis_writable()
Cis_file()
Dis_readable()
What does is_file() check?
AIf file is readable
BIf path is a directory
CIf path is a regular file
DIf file exists
Explain how to check if a file exists and is readable in PHP.
Think about first confirming the file is there, then if you can read it.
You got /3 concepts.
    Describe the difference between is_file() and is_dir().
    One checks files, the other checks folders.
    You got /3 concepts.