有几种方法可以去除PHP字符串的最后一个字符:
$str = "Hello World";
$str = substr($str, 0, -1);
echo $str; // 输出: Hello Worl
$str = "你好,世界";
$str = mb_substr($str, 0, -1);
echo $str; // 输出: 你好,世
$str = "Hello World";
$str = rtrim($str, $str[strlen($str)-1]);
echo $str; // 输出: Hello Worl
$str = "Hello World";
$str = preg_replace("/.$/", "", $str);
echo $str; // 输出: Hello Worl