PageRenderTime 24ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/bad/ext/standard/tests/strings/strtolower.php

http://github.com/facebook/hiphop-php
PHP | 57 lines | 43 code | 7 blank | 7 comment | 5 complexity | 9cecf04d3b2c139a3cb7dbedbb28aba4 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?php
  2. /* Prototype:
  3. string strtolower ( string $str );
  4. Description:
  5. Returns string with all alphabetic characters converted to lowercase.
  6. */
  7. if( substr(PHP_OS, 0, 3) == 'WIN') {
  8. setlocale(LC_ALL, 'C');
  9. } else {
  10. setlocale(LC_ALL, 'en_US.UTF-8');
  11. }
  12. echo "*** Testing strtolower() with 128 chars ***\n";
  13. for ($i=0; $i<=127; $i++){
  14. $char = chr($i);
  15. print(bin2hex($char))." => ".(bin2hex(strtolower("$char")))."\n";
  16. }
  17. echo "*** Testing strlower() with basic strings ***\n";
  18. $str = "Mary Had A liTTle LAmb and ShE loveD IT So\n";
  19. var_dump(strtolower($str));
  20. echo "\n*** Testing strtolower() with various strings ***";
  21. /* strings to pass strtolower() */
  22. $strings = array (
  23. "",
  24. "string",
  25. "stRINg0234",
  26. "1.233.344StrinG12333",
  27. "$$$$$$!!!!@@@@@@@ ABCDEF !!!***",
  28. "ABCD\0abcdABCD",
  29. NULL,
  30. TRUE,
  31. FALSE,
  32. array()
  33. );
  34. $count = 0;
  35. /* loop through to check possible variations */
  36. foreach ($strings as $string) {
  37. echo "\n-- Iteration $count --\n";
  38. var_dump( strtolower($string) );
  39. $count++;
  40. }
  41. echo "\n*** Testing strtolower() with two different case strings ***\n";
  42. if (strtolower("HeLLo woRLd") === strtolower("hEllo WORLD"))
  43. echo "strings are same, with Case Insensitive\n";
  44. else
  45. echo "strings are not same\n";
  46. echo "\n*** Testing error conditions ***";
  47. var_dump( strtolower() ); /* Zero arguments */
  48. var_dump( strtolower("a", "b") ); /* Arguments > Expected */
  49. echo "*** Done ***";
  50. ?>