split_error_001.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Test split() function : error conditions - wrong number of args
  3. --FILE--
  4. <?php
  5. /* Prototype : proto array split(string pattern, string string [, int limit])
  6. * Description: Split string into array by regular expression
  7. * Source code: ext/standard/reg.c
  8. * Alias to functions:
  9. */
  10. echo "*** Testing split() : error conditions - wrong number of args ***\n";
  11. //Test split with one more than the expected number of arguments
  12. echo "\n-- Testing split() function with more than expected no. of arguments --\n";
  13. $pattern = 'string_val';
  14. $string = 'string_val';
  15. $limit = 10;
  16. $extra_arg = 10;
  17. var_dump( split($pattern, $string, $limit, $extra_arg) );
  18. // Testing split with one less than the expected number of arguments
  19. echo "\n-- Testing split() function with less than expected no. of arguments --\n";
  20. $pattern = 'string_val';
  21. var_dump( split($pattern) );
  22. echo "Done";
  23. ?>
  24. --EXPECTF--
  25. *** Testing split() : error conditions - wrong number of args ***
  26. -- Testing split() function with more than expected no. of arguments --
  27. Deprecated: Function split() is deprecated in %s on line %d
  28. Warning: split() expects at most 3 parameters, 4 given in %s on line %d
  29. NULL
  30. -- Testing split() function with less than expected no. of arguments --
  31. Deprecated: Function split() is deprecated in %s on line %d
  32. Warning: split() expects at least 2 parameters, 1 given in %s on line %d
  33. NULL
  34. Done