What is the best method in PHP to split a string containing a file path into the directory path and file name?

When dealing with file paths in PHP, you can use the `dirname()` and `basename()` functions to split a string containing a file path into the directory path and file name. The `dirname()` function returns the directory component of the path, while `basename()` returns the file name component.

$file_path = "/path/to/directory/file.txt";

$directory_path = dirname($file_path);
$file_name = basename($file_path);

echo "Directory Path: " . $directory_path . "<br>";
echo "File Name: " . $file_name;