1--TEST-- 2Test mb_strpos() function : error conditions - Pass unknown encoding 3--SKIPIF-- 4<?php 5extension_loaded('mbstring') or die('skip'); 6function_exists('mb_strpos') or die("skip mb_strpos() is not available in this build"); 7?> 8--FILE-- 9<?php 10/* 11 * Pass an unknown encoding to mb_strpos() to test behaviour 12 */ 13 14echo "*** Testing mb_strpos() : error conditions ***\n"; 15$haystack = 'Hello, world'; 16$needle = 'world'; 17$offset = 2; 18$encoding = 'unknown-encoding'; 19 20try { 21 var_dump( mb_strpos($haystack, $needle, $offset, $encoding) ); 22} catch (\ValueError $e) { 23 echo $e->getMessage() . \PHP_EOL; 24} 25 26?> 27--EXPECT-- 28*** Testing mb_strpos() : error conditions *** 29mb_strpos(): Argument #4 ($encoding) must be a valid encoding, "unknown-encoding" given 30