6 /* Prototype: string trim( string str [,string charlist] )
7 * Strip whitespace (or other characters) from the beginning and end of a string.
10 /* trim with unset/null/boolean variable - returns an empty string */
13 var_dump( trim($null_var) );
15 var_dump( trim($null_var) );
17 var_dump( trim($null_var) );
19 var_dump( trim($null_var) );
21 /* second argument charlist as null - does not trim any white spaces */
22 var_dump( trim("\ttesting trim", "") );
23 var_dump( trim(" \ttesting trim ", NULL) );
24 var_dump( trim("\ttesting trim ", true) );
26 /* Use of class and objects */
27 echo "\n*** Testing with OBJECTS ***\n";
30 public function __toString() {
35 var_dump( trim($obj, "Ot") );
37 /* String with embedded NULL */
38 echo "\n*** Testing with String with embedded NULL ***\n";
39 var_dump( trim("\x0n1234\x0005678\x0000efgh\xijkl\x0n1", "\x0n1") );
47 echo "\n*** Testing with heredoc string ***\n";
48 var_dump( trim($str, "us\ning") );
57 string(13) " testing trim"
58 string(17) " testing trim "
59 string(15) " testing trim "
61 *** Testing with OBJECTS ***
64 *** Testing with String with embedded NULL ***
65 string(22) "234
\005678
\000efgh\xijkl"
67 *** Testing with heredoc string ***
68 string(12) " heredoc str"