rtrim_basic.phpt 1.5 KB

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