1--TEST-- 2Test trim() function 3--FILE-- 4<?php 5/* trim with unset/null/boolean variable - returns an empty string */ 6echo "\n"; 7$null_var = NULL; 8var_dump( trim($null_var) ); 9$null_var = ""; 10var_dump( trim($null_var) ); 11$null_var = 0; 12var_dump( trim($null_var) ); 13$bool_val = true; 14var_dump( trim($null_var) ); 15 16/* second argument charlist as null - does not trim any white spaces */ 17var_dump( trim("\ttesting trim", "") ); 18var_dump( trim(" \ttesting trim ", NULL) ); 19var_dump( trim("\ttesting trim ", true) ); 20 21/* Use of class and objects */ 22echo "\n*** Testing with OBJECTS ***\n"; 23class string1 24{ 25 public function __toString() { 26 return "Object"; 27 } 28} 29$obj = new string1; 30var_dump( trim($obj, "Ot") ); 31 32/* String with embedded NULL */ 33echo "\n*** Testing with String with embedded NULL ***\n"; 34var_dump( trim("\x0n1234\x0005678\x0000efgh\xijkl\x0n1", "\x0n1") ); 35 36/* heredoc string */ 37$str = <<<EOD 38us 39ing heredoc string 40EOD; 41 42echo "\n*** Testing with heredoc string ***\n"; 43var_dump( trim($str, "us\ning") ); 44 45echo "\nDone"; 46?> 47--EXPECT-- 48string(0) "" 49string(0) "" 50string(1) "0" 51string(1) "0" 52string(13) " testing trim" 53string(17) " testing trim " 54string(15) " testing trim " 55 56*** Testing with OBJECTS *** 57string(4) "bjec" 58 59*** Testing with String with embedded NULL *** 60string(22) "2340567800efgh\xijkl" 61 62*** Testing with heredoc string *** 63string(12) " heredoc str" 64 65Done 66