php file_get_contents follow redirect 1

php file_get_contents follow redirect

$context = stream_context_create(
    array(
        'http' => array(
            'follow_location' => true/false
        )
    )
);

$html = file_get_contents('http://www.example.com/', false, $context);

var_dump($http_response_header);

Here is what the above code is Doing:
1. Create a stream context with the follow_location option set to true or false.
2. Use file_get_contents() to fetch the page.
3. Use var_dump() to print the HTTP response headers.

Similar Posts