explode_variation6.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --TEST--
  2. Test explode() function : usage variations - misc tests
  3. --FILE--
  4. <?php
  5. echo "*** Testing explode() function: misc tests ***\n";
  6. $str = "one\x00two\x00three\x00four";
  7. echo "\n-- positive limit with null separator --\n";
  8. $e = test_explode("\x00", $str, 2);
  9. echo "\n-- negative limit (since PHP 5.1) with null separator --\n";
  10. $e = test_explode("\x00", $str, -2);
  11. echo "\n-- unknown string --\n";
  12. $e = test_explode("fred", $str,1);
  13. echo "\n-- limit = 0 --\n";
  14. $e = test_explode("\x00", $str, 0);
  15. echo "\n-- limit = -1 --\n";
  16. $e = test_explode("\x00", $str, -1);
  17. echo "\n-- large limit = -100 --\n";
  18. $e = test_explode("\x00", $str, 100);
  19. function test_explode($delim, $string, $limit)
  20. {
  21. $e = explode($delim, $string, $limit);
  22. foreach ( $e as $v)
  23. {
  24. var_dump(bin2hex($v));
  25. }
  26. }
  27. ?>
  28. --EXPECT--
  29. *** Testing explode() function: misc tests ***
  30. -- positive limit with null separator --
  31. string(6) "6f6e65"
  32. string(28) "74776f00746872656500666f7572"
  33. -- negative limit (since PHP 5.1) with null separator --
  34. string(6) "6f6e65"
  35. string(6) "74776f"
  36. -- unknown string --
  37. string(36) "6f6e650074776f00746872656500666f7572"
  38. -- limit = 0 --
  39. string(36) "6f6e650074776f00746872656500666f7572"
  40. -- limit = -1 --
  41. string(6) "6f6e65"
  42. string(6) "74776f"
  43. string(10) "7468726565"
  44. -- large limit = -100 --
  45. string(6) "6f6e65"
  46. string(6) "74776f"
  47. string(10) "7468726565"
  48. string(8) "666f7572"