Q
Which PHP function returns the filename component of a path?

Answer & Solution

Answer: Option A
Solution:
basename() returns the filename component of a path, such as extracting 'file.txt' from '/path/to/file.txt'.
Related Questions on Average

Which PHP function creates a directory?

A). mkdir()

B). scandir()

C). rmdir()

D). chdir()

What does the PHP function scandir() do?

A). Returns an array of files and directories in a directory

B). Returns the contents of a file

C). Returns the current working directory

D). Returns the size of a file

What does the PHP function dirname() return?

A). Directory name component of a path

B). Filename component of a path

C). Absolute path of a file

D). Parent directory of the current directory

Which PHP function extracts the extension of a file path?

A). pathinfo()

B). dirname()

C). realpath()

D). basename()

What is the PHP function to check if a path is a directory?

A). is_dir()

B). is_file()

C). file_exists()

D). exists()

What does the PHP function is_file() check for?

A). Checks if a path is a regular file

B). Checks if a path is a directory

C). Checks if a file is writable

D). Checks if a file is readable

What does the PHP function pathinfo() return?

A). Information about a file path

B). Extension of a file

C). Directory name component of a path

D). Size of a file

Which PHP function removes a directory?

A). rmdir()

B). mkdir()

C). chdir()

D). scandir()

Which PHP function changes the current directory?

A). chdir()

B). mkdir()

C). rmdir()

D). scandir()

Which PHP function returns the parent directory of a file?

A). dirname()

B). realpath()

C). pathinfo()

D). basename()