$str = " Hello World! ";
echo "Without trim: " . $str;
echo "<br>";
echo "With trim: " . trim($str);
The HTML output of the code above will be (View Source):
<!DOCTYPE html>
<html>
<body>
Without trim: Hello World!
With trim: Hello World!
</body>
</html>
The browser output of the code above will be:Without trim: Hello World!
With trim: Hello World!