参数 | 描述 |
---|---|
string | 必需。规定要检查的字符串。 |
charlist |
可选。规定要转换的字符串。如果省略该参数,则删除以下所有字符:
|
<html>
<body>
<?php
$str = " Hello World! ";
echo "Without trim: " . $str;
echo "<br />";
echo "With trim: " . trim($str)
;
?>
<body>
<html>
输出:
Without trim: Hello World! With trim: Hello World!
HTML 源码:
<html> <body> Without trim: Hello World! <br />With trim: Hello World! </body> </html>
<?php
$str = "\r\nHello World!\r\n";
echo "Without trim: " . $str;
echo "<br />";
echo "With trim: " . trim($str)
;
?>
输出:
Without trim: Hello World! With trim: Hello World!
HTML 源码:
<html> <body> Without trim: Hello World! <br />With trim: Hello World! </body> </html>
制作:
http://www.7di.net 生活网搜集整理 参考: http://www.w3school.com.cn/php/func_string_trim.asp |