trim_basic.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. --TEST--
  2. Test trim() function : basic functionality
  3. --FILE--
  4. <?php
  5. echo "*** Testing trim() : basic functionality ***\n";
  6. $text = " \t\r\n\0\x0B ---These are a few words--- \t\r\n\0\x0B ";
  7. $hello = "!===Hello World===!";
  8. $binary = "\x0A\x0DExample string\x0A\x0D";
  9. echo "\n-- Trim string with all white space characters --\n";
  10. var_dump(trim($text));
  11. echo "\n-- Trim non-whitespace from a string --\n";
  12. var_dump(trim($hello, "=!"));
  13. echo "\n-- Trim some non-white space characters from a string --\n";
  14. var_dump(trim($hello, "Hdle"));
  15. echo "\n-- Trim the ASCII control characters at the beginning of a string --\n";
  16. var_dump(trim($binary, "\x00..\x1F"));
  17. ?>
  18. --EXPECT--
  19. *** Testing trim() : basic functionality ***
  20. -- Trim string with all white space characters --
  21. string(27) "---These are a few words---"
  22. -- Trim non-whitespace from a string --
  23. string(11) "Hello World"
  24. -- Trim some non-white space characters from a string --
  25. string(19) "!===Hello World===!"
  26. -- Trim the ASCII control characters at the beginning of a string --
  27. string(14) "Example string"