What is the issue with using the file() function in PHP and why is URL file-access disabled in the server configuration?

The issue with using the file() function in PHP is that it may not work if URL file-access is disabled in the server configuration for security reasons. To solve this issue, you can use cURL to fetch the contents of a URL instead of relying on file().

// Using cURL to fetch the contents of a URL
$url = 'https://example.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);

// Output the contents of the URL
echo $output;