echo substr("kling.cn/", -1);
// 返回结果: /
echo mb_substr("张良人博客", -1);
// 返回结果:客
说明:
1、substr(),对中文字符串兼容性不好
2、mb_substr(),可以处理中文字符串
$str = "www.baidu.com";
$len = strlen($str)-1;
echo $str{$len};
$str = "www.baidu.com/";
echo substr_replace($str ,"",-1);
输出结果:www.baidu.com
$str = "feiniaomy.com/";
echo substr($str, 0, -1);
$str = '飞鸟慕鱼博客站';
echo mb_substr($str,0,-1);
运行结果:feiniaomy.com
$str = "abcdefd";
echo rtrim($str,'d');
运行结果:abcdef