mb_strripos_error1.phpt 1.6 KB

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