因此,我动态生成了遵循以下格式的页面:
http://example.com/name/first_name/last_name/John%2C+Smith
输出url最后一部分的php代码是什么?
所以,它变成了“John,Smith”。
非常感谢。
编辑:
我意识到该 URL 以另一个 /
结尾,并且下面给出的答案没有找到它。我应该做出什么改变?
http://example.com/name/first_name/last_name/John%2C+Smith/
编辑2:
因此,链接是动态生成的,如下所示:
href="http://example.com/name/first_name/last_name/<?php echo $full_name ?>"
最佳答案
分割 url,获取最后一个片段,然后对其进行 URL 解码:
<?
$urlarray=explode("/",$url);
$end=$urlarray[count($urlarray)-1];
$end=urldecode($end);
//go on using $end then
?>
关于php - 在php中输出部分URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31283882/