What function in PHP can be used to check if a file exists and if it is a regular file?

To check if a file exists and if it is a regular file in PHP, you can use the `file_exists()` function to check if the file exists, and the `is_file()` function to check if it is a regular file. By combining these two functions, you can effectively determine if a file exists and if it is a regular file.

$file_path = 'example.txt';

if (file_exists($file_path) && is_file($file_path)) {
    echo "File exists and is a regular file.";
} else {
    echo "File does not exist or is not a regular file.";
}