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