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