php file get contents follow redirect

Solutions on MaxInterview for php file get contents follow redirect by the best coders in the world

showing results for - "php file get contents follow redirect"
Hanna
20 Sep 2020
1$context = stream_context_create(
2    array(
3        'http' => array(
4            'follow_location' => true/false
5        )
6    )
7);
8
9$html = file_get_contents('http://www.example.com/', false, $context);
10
11var_dump($http_response_header);
12
Marco
17 Nov 2018
1$ch = curl_init();
2curl_setopt($ch, CURLOPT_URL, $url);
3curl_setopt($ch, CURLOPT_HEADER, TRUE);
4curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
5curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
6$a = curl_exec($ch);
7if(preg_match('#Location: (.*)#', $a, $r))
8 $l = trim($r[1]);