1--TEST--
2Test trim() function : basic functionality
3--FILE--
4<?php
5
6/* Prototype  : string trim  ( string $str  [, string $charlist  ] )
7 * Description: Strip whitespace (or other characters) from the beginning and end of a string.
8 * Source code: ext/standard/string.c
9*/
10
11echo "*** Testing trim() : basic functionality ***\n";
12
13$text  = "  \t\r\n\0\x0B  ---These are a few words---  \t\r\n\0\x0B  ";
14$hello  = "!===Hello World===!";
15$binary = "\x0A\x0DExample string\x0A\x0D";
16
17echo "\n-- Trim string with all white space characters --\n";
18var_dump(trim($text));
19
20echo "\n-- Trim non-whitespace from a string --\n";
21var_dump(trim($hello, "=!"));
22
23echo "\n-- Trim some non-white space characters from a string --\n";
24var_dump(trim($hello, "Hdle"));
25
26echo "\n-- Trim the ASCII control characters at the beginning of a string --\n";
27var_dump(trim($binary, "\x00..\x1F"));
28
29?>
30===DONE===
31--EXPECT--
32*** Testing trim() : basic functionality ***
33
34-- Trim string with all white space characters --
35string(27) "---These are a few words---"
36
37-- Trim non-whitespace from a string --
38string(11) "Hello World"
39
40-- Trim some non-white space characters from a string --
41string(19) "!===Hello World===!"
42
43-- Trim the ASCII control characters at the beginning of a string --
44string(14) "Example string"
45===DONE===
46