I am using the Following code
<?php
$url = 'http://www.ewwsdf.org/012Q/rhod-05.php?arg=value#anchor';
$parse = parse_url($url);
$lnk= "http://".$parse['host'].$parse['path'];
echo $lnk;
?>
This is giving me the output as
How can i modify the code so that i get the output as
Just need the Directory name without the file name
( I actually need the link so that i can link up the images which are on the pages, By appending the link behind the image Eg http://www.ewwsdf.org/012Q/hi.jpg )
Just need the Directory name without the file name
Then use dirname()
, eg
$lnk= "http://".$parse['host'].dirname($parse['path']);
$lnk = "http://".$parse['host'].dirname($parse['path']).'/';
dirname
返回父目录的路径。
使用pathinfo()代替,它显示已经解析的相关信息
you could do something like this:
$sections = explode("/", $_SERVER['REQUEST_URI']);
$folder = $sections[1];
$url = "http://www.ewwsdf.org/".$folder."/";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.