What are the differences between using a function and an IF statement to check for the existence of a PHP file?

When checking for the existence of a PHP file, using a function like file_exists() is more efficient and cleaner than using an IF statement with the file_exists() function. The function directly returns a boolean value based on whether the file exists or not, eliminating the need for an additional conditional check.

// Using a function to check for the existence of a PHP file
$file_path = 'example.php';

if (file_exists($file_path)) {
    echo "The file exists.";
} else {
    echo "The file does not exist.";
}