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?
✗ Incorrect
opendir() is the correct function to open a directory handle.What does
readdir() return when it reaches the end of a directory?✗ Incorrect
readdir() returns false when no more entries are available.Which function checks if a path is a directory?
✗ Incorrect
is_dir() returns true if the path is a directory.How do you close a directory handle in PHP?
✗ Incorrect
closedir() closes an open directory handle.Which function creates a new directory?
✗ Incorrect
mkdir() creates a new directory.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.