欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP trim() 函數(shù)

定義和用法

trim() 函數(shù)從字符串的兩端刪除空白字符和其他預(yù)定義字符。

語(yǔ)法

trim(string,charlist)
參數(shù) 描述
string 必需。規(guī)定要檢查的字符串。
charlist 可選。規(guī)定要轉(zhuǎn)換的字符串。如果省略該參數(shù),則刪除以下所有字符:
  • "\0" - NULL
  • "\t" - tab
  • "\n" - new line
  • "\x0B" - 縱向列表符
  • "\r" - 回車
  • " " - 普通空白字符

例子

例子 1

<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>

例子 2

<?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>