0
0
PHPprogramming~5 mins

Directory operations in PHP - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What PHP function is used to open a directory for reading?
The opendir() function is used to open a directory and prepare it for reading its contents.
Click to reveal answer
beginner
How do you read entries from an opened directory in PHP?
Use the readdir() function to read the next entry (file or directory name) from the directory handle.
Click to reveal answer
beginner
What is the purpose of the closedir() function in PHP?
It closes an open directory handle, freeing up system resources.
Click to reveal answer
beginner
How can you check if a directory exists in PHP?
Use the is_dir() function, which returns true if the path is a directory, otherwise false.
Click to reveal answer
beginner
Which PHP function creates a new directory?
The mkdir() function creates a new directory with specified permissions.
Click to reveal answer
Which function opens a directory for reading in PHP?
Afopen()
Breadfile()
Copendir()
Ddir_open()
What does readdir() return when it reaches the end of a directory?
Afalse
Bnull
Cempty string
D0
Which function checks if a path is a directory?
Afile_exists()
Bis_file()
Cdir_exists()
Dis_dir()
How do you close a directory handle in PHP?
Aclose()
Bclosedir()
Cdir_close()
Denddir()
Which function creates a new directory?
Amkdir()
Bnewdir()
Ccreatedir()
Ddir_create()
Explain the steps to read all files and directories inside a directory in PHP.
Think about opening, reading each entry, and then closing.
You got /4 concepts.
    How can you safely create a directory only if it does not already exist in PHP?
    Check first, then create.
    You got /3 concepts.