Source Code:
(back to article)
<?php $url = "https://jsonplaceholder.typicode.com/posts/1"; $options = ['http' => ['user_agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36']]; $context = stream_context_create($options); $response = file_get_contents($url, false, $context); if ($response === false) { echo "Failed to retrieve the contents of the URL."; } else { echo $response; } ?>
Result:
Report an issue