I tried doing this:
$urls = array(
"https://www.gov.sg/"
);
foreach ($urls as $url) {
d($url);
// $url = "http://www.google.com";
$data = file_get_contents($url);
d($data);
}
d() is a 3rd-party function like var_dump().
I keep on getting $data = false. It seems like any page from the domain is doing that.
When I tried another domain like google.com, it worked.
The page is valid, I tried it on a browser.
The following similar posts suggest URL encoding issues, and enabling allow_url_fopen, but these don't really apply here: PHP file_get_contents returning false PHP file_get_contents returning false
Why is the function returning false? Also, in general, is there a way to check why a file_get_contents is returning false? Is there a way for PHP to dump the error?