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