mb_strlen_error1.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. Test mb_strlen() function : error conditions - pass incorrect number of args
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('mbstring') or die('skip');
  6. function_exists('mb_strlen') or die("skip mb_strlen() is not available in this build");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : int mb_strlen(string $str [, string $encoding])
  11. * Description: Get character numbers of a string
  12. * Source code: ext/mbstring/mbstring.c
  13. */
  14. /*
  15. * Pass mb_strlen an incorrect number of arguments to test behaviour
  16. */
  17. echo "*** Testing mb_strlen() : error conditions ***\n";
  18. // Zero arguments
  19. echo "\n-- Testing mb_strlen() function with Zero arguments --\n";
  20. var_dump( mb_strlen() );
  21. //Test mb_strlen with one more than the expected number of arguments
  22. echo "\n-- Testing mb_strlen() function with more than expected no. of arguments --\n";
  23. $str = 'string_val';
  24. $encoding = 'string_val';
  25. $extra_arg = 10;
  26. var_dump( mb_strlen($str, $encoding, $extra_arg) );
  27. echo "Done";
  28. ?>
  29. --EXPECTF--
  30. *** Testing mb_strlen() : error conditions ***
  31. -- Testing mb_strlen() function with Zero arguments --
  32. Warning: mb_strlen() expects at least 1 parameter, 0 given in %s on line %d
  33. bool(false)
  34. -- Testing mb_strlen() function with more than expected no. of arguments --
  35. Warning: mb_strlen() expects at most 2 parameters, 3 given in %s on line %d
  36. bool(false)
  37. Done