PHP File_exist() not working – Checking if File Exist in WordPress Theme Directory

Most of this code is unnecessary. You’re attempting to convert a URL to a path when you could just use the function that returns a path.

$path = get_theme_file_path( 'archive.php' );

if ( file_exists( $path ) ) {
    echo 'File Found: '. $path;
} else {
    echo 'File Not Found: '. $path;
}