1$opts = [
2 "http" => [
3 "method" => "GET",
4 "header" => "Accept-language: en\r\n" .
5 "Cookie: foo=bar\r\n"
6 ]
7];
8
9// DOCS: https://www.php.net/manual/en/function.stream-context-create.php
10$context = stream_context_create($opts);
11
12// Open the file using the HTTP headers set above
13// DOCS: https://www.php.net/manual/en/function.file-get-contents.php
14$file = file_get_contents('http://www.example.com/', false, $context);
1function url_get_contents ($Url) {
2 if (!function_exists('curl_init')){
3 die('CURL is not installed!');
4 }
5 $ch = curl_init();
6 curl_setopt($ch, CURLOPT_URL, $Url);
7 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
8 $output = curl_exec($ch);
9 curl_close($ch);
10 return json_decode($output,JSON_OBJECT_AS_ARRAY);
11}