Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by all

When I checking the errors in error_log it showing the error

[10-Apr-2019 03:35:52 UTC] PHP Warning: file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /…/status.php on line 125
[10-Apr-2019 03:35:52 UTC] PHP Warning: file_get_contents(l): failed to open stream: no suitable wrapper could be found in /…/status.php on line 125
[10-Apr-2019 03:35:52 UTC] PHP Fatal error: Uncaught Exception: String could not be parsed as XML in /…/status.php:126
Stack trace:
#0 /…/status.php(126): SimpleXMLElement->__construct(’’)
#1 {main}
thrown in /…/status.php on line 126

How to fix this error?

Hello,

You have to show us the code and tell us what you are trying to do so that someone can help you.
I have never worked with PHP but I googled the error and I found this:


But I’m not sure if this is what you are talking about …

<?php
ini_set("allow_url_fopen", 1);
echo "<table><tr><th>Monitor Name</th><th>Status</th><th>Total Uptime</th></tr>";
$apiKey = "u82276-fd9b862ad297e19ff5b05280";
$url = "http://api.uptimerobot.com/getMonitors?apiKey=" . $apiKey . "&format=xml";
$xml = file_get_contents($url);
$xml = new SimpleXMLElement ($xml);
foreach($xml->monitor as $monitor) {
  echo "<tr>";
  echo "<td>";
  echo $monitor['friendlyname'];
  echo "</td><td>";
  if ($monitor['status'] == 2) {
    echo "Online";
  }
  elseif ($monitor['status'] == 9) {
    echo "Offline";
  }
  else {
    echo "Not Available";
  }
  echo "</td><td>";
  if ($monitor['alltimeuptimeratio'] > 95) {
    echo "<b style=\"color:green;\">" . $monitor['alltimeuptimeratio'] . "%</b></td></tr>";
  }
  else {
    echo "<b style=\"color:red;\">" . $monitor['alltimeuptimeratio'] . "%</b></td></tr>";
  }
}
echo "</table>";
?>

On sixth line I am getting error.

Ask your hosting provider to enable -> allow_url_fopen