it's not checking the file. it's checking the string.
the if statement could be
if("dog" != "")
if("dog" != "cat")
it's string comparison, that just happens to use the string "index.php".
it's not checking for the existence of the file, just that the first string ("index.php") is not the same as the second string ("")