What are the advantages and disadvantages of using fsockopen for checking the availability of a website in PHP scripts?

When checking the availability of a website in PHP scripts, using fsockopen can be advantageous because it allows for more control over the connection process and provides detailed error handling. However, fsockopen can be slower than other methods such as cURL and may require more code to implement properly.

<?php

$host = 'www.example.com';
$port = 80;
$timeout = 5;

$fp = @fsockopen($host, $port, $errno, $errstr, $timeout);

if ($fp) {
    echo 'Website is available';
    fclose($fp);
} else {
    echo 'Website is not available';
}

?>