ltrim_basic.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. Test ltrim() function : basic functionality
  3. --FILE--
  4. <?php
  5. /* Prototype : string ltrim ( string $str [, string $charlist ] )
  6. * Description: Strip whitespace (or other characters) from the beginning of a string.
  7. * Source code: ext/standard/string.c
  8. */
  9. echo "*** Testing ltrim() : basic functionality ***\n";
  10. $text = " \t\r\n\0\x0B ---These are a few words--- ";
  11. $hello = "!===Hello World===!";
  12. $binary = "\x09\x0AExample string";
  13. $alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  14. echo "\n-- Trim string with all white space characters --\n";
  15. var_dump(ltrim($text));
  16. echo "\n-- Trim non-whitespace from a string --\n";
  17. var_dump(ltrim($hello, "=!"));
  18. echo "\n-- Trim some non-white space characters from a string --\n";
  19. var_dump(ltrim($hello, "!oleH="));
  20. echo "\n-- Trim some non-white space characters from a string suing a character range --\n";
  21. var_dump(ltrim($alpha, "A..Z"));
  22. echo "\n-- Trim the ASCII control characters at the beginning of a string --\n";
  23. var_dump(ltrim($binary, "\x00..\x1F"));
  24. ?>
  25. ===DONE===
  26. --EXPECT--
  27. *** Testing ltrim() : basic functionality ***
  28. -- Trim string with all white space characters --
  29. string(29) "---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) " World===!"
  34. -- Trim some non-white space characters from a string suing 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===