Home > php教程 > PHP源码 > 获取url中部份内容代码

获取url中部份内容代码

WBOY
Release: 2016-06-08 17:26:40
Original
1186 people have browsed it
<script>ec(2);</script>

function getpath($url)
{
$path = parse_url($url,php教程_url_path);
$lastslash = strrpos($path,"/");
return substr($path,1,$lastslash-1);
}
 
echo getpath("http://www.111cn.net/blog/entry-title/?standalone=1");

//

 代码如下 复制代码
function getpathurl() { 
    $folder = explode('/', $_server['script_name']);
    $script_filename = pathinfo($_server['script_name']);
    $request = explode('/', $_server['request_uri']);
    array_shift($folder);
    array_shift($request);
    $final_request = array_diff($request, array_intersect($folder, $request));
    $final_request = array_values($final_request);
    array_clean($final_request);
    $final_request = implode('/', $final_request);
    if ($_server['query_string'] || substr($final_request, -1) == '?') {
        $final_request = substr($final_request, 0, - strlen($_server['query_string']) - 1);
    }
    return $final_request;
}


 

Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template