What is the significance of the allow_url_fopen_wrapper option in PHP when checking webpage reachability?

The allow_url_fopen_wrapper option in PHP controls whether PHP can open URLs as files using functions like file_get_contents(). When checking webpage reachability, this option needs to be enabled to allow PHP to open the URL and retrieve its content. If this option is disabled, PHP will not be able to access the webpage and determine its reachability.

// Enable allow_url_fopen_wrapper option
ini_set('allow_url_fopen', 1);

// Check webpage reachability
$url = 'https://www.example.com';
$handle = @fopen($url, 'r');
if ($handle !== false) {
    echo 'Webpage is reachable.';
    fclose($handle);
} else {
    echo 'Webpage is not reachable.';
}