php - 在php中输出部分URL

标签 php urldecode

因此,我动态生成了遵循以下格式的页面:

 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/

相关文章:

php - MySQL 首选项查找器

php - 无法从 PHP exec() 执行的 Python 脚本

php - 如何在 Laravel 中验证电子邮件地址域?

c# - 如何正确使用UrlEncode和Decode

html - 为什么这个 %2B 字符串被 urldecoded?

PHP - 自动检测(原始)urlencode

php - Zend Framework 2 TableGateway fetchAll 方法返回空结果集但表包含数据

javascript - jQuery urlencode/decode 补丁帮助

php - 如何解码 php 中的 url,其中 url 使用 encodeURIComponent() 编码

php - 关于低敏感度用户帐户的双盐认证的意见?