Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$url = 'http://www.example.com/';
$fp = fopen($url, 'r');
$meta_data = stream_get_meta_data($fp);
foreach ($meta_data['wrapper_data'] as $response) {
/* 我们是否被重定向了? */
if (strtolower(substr($response, 0, 10)) == 'location: ') {
/* 更新我们被重定向后的 $url */
$url = substr($response, 10);
}
}
?>