How can the response from a server be evaluated in PHP without using file_exists()?

When evaluating the response from a server in PHP without using file_exists(), you can use the get_headers() function to check the response headers of a URL. This function returns an array of headers, including the HTTP response code. You can then check if the response code is in the 200 range to determine if the server responded successfully.

$url = 'https://www.example.com';
$headers = get_headers($url);

if(strpos($headers[0], '200') !== false){
    echo 'Server responded successfully';
} else {
    echo 'Server did not respond successfully';
}