php猎取跳转地点的办法:起首创立一个PHP示例代码文件;而后猎取一个短地点;接着经过“get_headers()”函数把头部信息猎取到;最初剖析跳转地点便可。
PHP猎取跳转后的实在地点
猎取到一个短衔接,需求将短衔接转换成实在的网址,经过查材料,发现 PHP 提供了一个函数 get_headers() ,能够实现这个义务,先把 头部信息猎取到,而后再剖析跳转地点便可:
$url = 'http://t.cn/h5mwx'; $headers = get_headers($url, TRUE); print_r($headers); //输入跳转到的网址 echo $headers['Location'];
后果:
Array ( [0] => HTTP/1.1 302 Found [Date] => Array ( [0] => Mon, 24 Jun 2019 09:35:18 GMT [1] => Mon, 24 Jun 2019 09:35:18 GMT ) [Content-Type] => Array ( [0] => text/html;charset=UTF-8 [1] => text/html ) [Content-Length] => Array ( [0] => 202 [1] => 14615 ) [Connection] => close [Set-Cookie] => Array ( [0] => aliyungf_tc=AQAAAAT06182sQMAe4N7dySC5VJrv03L; Path=/; HttpOnly [1] => BAIDUID=11F195A5E7DFE34FC3BF57618AF40AF5:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.百度.com [2] => BIDUPSID=11F195A5E7DFE34FC3BF57618AF40AF5; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.百度.com [3] => PSTM=1561368918; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.百度.com ) [Server] => Array ( [0] => nginx [1] => BWS/1.1 ) [Location] => http://www.百度.com [1] => HTTP/1.0 200 OK [Accept-Ranges] => bytes [Cache-Control] => no-cache [Etag] => "5d0888c3-3917" [Last-Modified] => Tue, 18 Jun 2019 06:46:27 GMT [P3p] => CP=" OTI DSP COR IVA OUR IND COM " [Pragma] => no-cache [Vary] => Accept-Encoding [X-Ua-Compatible] => IE=Edge,chrome=1 ) http://www.百度.com
不少相干常识,请拜访PHP中文网!
以上就是php若何猎取跳转后的实在地点的具体内容,更多请存眷资源魔其它相干文章!
标签: php 地址 php教程 php故障解决 php使用问题
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
抱歉,评论功能暂时关闭!