file_get_contents (http://maisqi.com/this-does-not-exist)
context: Array
(
[follow_location] => 0
[max_redirects] => 0
[ignore_errors] =>
)
The result: boolean
$http_response_header: NULL
1
file_get_contents (http://an-unexisting-valid-domain.nonexistent-tld/some-resource)
context: Array
(
[follow_location] => 0
[max_redirects] => 0
[ignore_errors] =>
)
The result: boolean
$http_response_header: NULL
1
file_get_contents (http://an-unexisting-valid-domain.nonexistent-tld/some-resource)
context: Array
(
[ignore_errors] =>
)
The result: boolean
$http_response_header: NULL
1
This code
<?php
$cfg = array ('follow_location' => 0, 'max_redirects' => 0, 'ignore_errors' => false);
test ('http://maisqi.com/this-does-not-exist', $cfg);
test ('http://an-unexisting-valid-domain.nonexistent-tld/some-resource', $cfg);
$cfg = array ('ignore_errors' => false);
test ('http://an-unexisting-valid-domain.nonexistent-tld/some-resource', $cfg);
echo '<h1>This code</h1><pre>';
echo htmlspecialchars (file_get_contents (__FILE__)), '</pre>';
function test ($uri, $cfg) {
echo '<h1>file_get_contents (', $uri, ')</h1><pre>', "\n";
echo 'context: ', print_r ($cfg, 1), "\n";
$context = stream_context_create (array ('http' => $cfg));
$res = @file_get_contents ($uri, 0, $context);
echo ' The result: ', gettype ($res), "\n";
echo ' $http_response_header: ', gettype ($http_response_header), "\n", print_r ($http_response_header), "\n";
echo '</pre>';
}