首頁 > php教程 > php手册 > PHP 获取网页301|302真实地址

PHP 获取网页301|302真实地址

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
發布: 2016-06-13 11:28:50
原創
1557 人瀏覽過

<span  1</span> <span function</span> getRealURL(<span $url</span><span ){
</span><span  2</span>     <span $header</span> = <span get_headers</span>(<span $url</span>,1<span );
</span><span  3</span>     <span if</span> (<span strpos</span>(<span $header</span>[0],'301') || <span strpos</span>(<span $header</span>[0],'302'<span )) {
</span><span  4</span>         <span if</span>(<span is_array</span>(<span $header</span>['Location'<span ])) {
</span><span  5</span>             <span return</span> <span $header</span>['Location'][<span count</span>(<span $header</span>['Location'])-1<span ];
</span><span  6</span>         }<span else</span><span {
</span><span  7</span>             <span return</span> <span $header</span>['Location'<span ];
</span><span  8</span> <span         }
</span><span  9</span>     }<span else</span><span  {
</span><span 10</span>         <span return</span> <span $url</span><span ;
</span><span 11</span> <span     }
</span><span 12</span> }            
登入後複製

 

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
怎麼學好php
來自於 1970-01-01 08:00:00
0
0
0
PHP擴充intl
來自於 1970-01-01 08:00:00
0
0
0
php數據獲取?
來自於 1970-01-01 08:00:00
0
0
0
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板