mb_strrchr_error1.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Test mb_strrchr() function : error conditions
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('mbstring') or die('skip');
  6. function_exists('mb_strrchr') or die("skip mb_strrchr() is not available in this build");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : string mb_strrchr(string haystack, string needle[, bool part[, string encoding]])
  11. * Description: Finds the last occurrence of a character in a string within another
  12. * Source code: ext/mbstring/mbstring.c
  13. * Alias to functions:
  14. */
  15. echo "*** Testing mb_strrchr() : error conditions ***\n";
  16. //Test mb_strrchr with one more than the expected number of arguments
  17. echo "\n-- Testing mb_strrchr() function with more than expected no. of arguments --\n";
  18. $haystack = b'string_val';
  19. $needle = b'string_val';
  20. $part = true;
  21. $encoding = 'string_val';
  22. $extra_arg = 10;
  23. var_dump( mb_strrchr($haystack, $needle, $part, $encoding, $extra_arg) );
  24. // Testing mb_strrchr with one less than the expected number of arguments
  25. echo "\n-- Testing mb_strrchr() function with less than expected no. of arguments --\n";
  26. $haystack = b'string_val';
  27. var_dump( mb_strrchr($haystack) );
  28. ?>
  29. ===DONE===
  30. --EXPECTF--
  31. *** Testing mb_strrchr() : error conditions ***
  32. -- Testing mb_strrchr() function with more than expected no. of arguments --
  33. Warning: mb_strrchr() expects at most 4 parameters, 5 given in %s on line %d
  34. bool(false)
  35. -- Testing mb_strrchr() function with less than expected no. of arguments --
  36. Warning: mb_strrchr() expects at least 2 parameters, 1 given in %s on line %d
  37. bool(false)
  38. ===DONE===