mb_strrpos_error2.phpt 946 B

1234567891011121314151617181920212223242526272829303132333435
  1. --TEST--
  2. Test mb_strrpos() function : error conditions - pass an unknown encoding
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('mbstring') or die('skip');
  6. function_exists('mb_strrpos') or die("skip mb_strrpos() is not available in this build");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : int mb_strrpos(string $haystack, string $needle [, int $offset [, string $encoding]])
  11. * Description: Find position of last occurrence of a string within another
  12. * Source code: ext/mbstring/mbstring.c
  13. */
  14. /*
  15. * Pass mb_strrpos() an encoding that doesn't exist
  16. */
  17. echo "*** Testing mb_strrpos() : error conditions ***\n";
  18. $haystack = 'This is an English string. 0123456789.';
  19. $needle = '123';
  20. $offset = 5;
  21. $encoding = 'unknown-encoding';
  22. var_dump(mb_strrpos($haystack, $needle , $offset, $encoding));
  23. echo "Done";
  24. ?>
  25. --EXPECTF--
  26. *** Testing mb_strrpos() : error conditions ***
  27. Warning: mb_strrpos(): Unknown encoding "unknown-encoding" in %s on line %d
  28. bool(false)
  29. Done