Php 修剪不会剥离空间

Php 修剪不会剥离空间,php,string,trim,Php,String,Trim,我读了很多答案,但从未找到解决办法 为什么这不适用于修剪? $test = trim('Whatever this is'); echo $test; 这项工作: $test= preg_replace('/\s+/', ' ', 'Whatever this is'); echo $test; Whatever this is 期望值: $test= preg_replace('/\s+/', ' ', 'Whatever this is'); echo $tes

我读了很多答案,但从未找到解决办法

为什么这不适用于修剪?

$test = trim('Whatever this     is');
echo $test;
这项工作:

$test= preg_replace('/\s+/', ' ', 'Whatever this     is');
echo $test;
Whatever this is
期望值:

$test= preg_replace('/\s+/', ' ', 'Whatever this     is');
echo $test;
Whatever this is
为什么第一个不行,而第二个不行?没有奇怪的字符,因为我直接在PHP代码中编写它们


请不要太快关闭此文件

trim
仅从字符串的开头和结尾删除空格。请参阅此项。

trim
仅从字符串的开头和结尾去除空格。请参考此。

php.net上
trim()
的第一句话:trim-删除字符串开头和结尾的空格(或其他字符),显然不只是为了查看。@Daan的第一句话实际上是“2016中国php大会”,但是的,谢谢!php.net上的
trim()
的第一句话:trim-删除字符串开头和结尾的空格(或其他字符),显然不只是为了查看。@Daan第一句话实际上是“2016中国php大会”,但是的,谢谢!