PHP Get the real address of web page 301|302_PHP tutorial

WBOY
Release: 2016-07-20 11:12:58
Original
922 people have browsed it

<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> }            
Copy after login

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/440410.htmlTechArticlegetRealURL( = ( ,1 ( ( [0],'301') || ( [0],'302' ( ( ['Location' ['Location'][ ( ['Location'])-1 } ['Location' } }...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!