1
0
mirror of https://github.com/php/php-src.git synced 2026-04-03 14:12:38 +02:00
Files
archived-php-src/ext/mbstring/tests/mb_strstr_error2.phpt
George Peter Banyard 90eeca2531 Convert some unknown encoding warnings to ValueErrors in ext/mbstring
Promotes only the warnings where the encoding comes only from a string.
Functions which accept an array of encodings will be fixed at a later stage.

Closes GH-5317
2020-03-31 16:34:18 +02:00

37 lines
1003 B
PHP

--TEST--
Test mb_strstr() function : error conditions
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip');
function_exists('mb_strstr') or die("skip mb_strstr() is not available in this build");
?>
--FILE--
<?php
/* Prototype : string mb_strstr(string haystack, string needle[, bool part[, string encoding]])
* Description: Finds first occurrence of a string within another
* Source code: ext/mbstring/mbstring.c
* Alias to functions:
*/
echo "*** Testing mb_strstr() : error conditions ***\n";
echo "\n-- Testing mb_strstr() with unknown encoding --\n";
$haystack = 'Hello, world';
$needle = 'world';
$encoding = 'unknown-encoding';
$part = true;
try {
var_dump( mb_strstr($haystack, $needle, $part, $encoding) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
?>
--EXPECT--
*** Testing mb_strstr() : error conditions ***
-- Testing mb_strstr() with unknown encoding --
mb_strstr(): Argument #4 ($encoding) must be a valid encoding, "unknown-encoding" given