1
0
mirror of https://github.com/php/php-src.git synced 2026-04-14 03:22:58 +02:00
Files
archived-php-src/ext/mbstring/tests/mb_strstr_empty_needle.phpt
George Peter Banyard 483efc7e50 Allow empty needles in mb_strpos and mb_strstr function family.
MBstring analogous implementation to 6d578482a9

Closes GH-4977
2020-01-07 22:53:35 +01:00

38 lines
987 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
--TEST--
Test mb_strstr() function : with empty needle
--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
mb_internal_encoding('UTF-8');
$string_ascii = 'abc def';
// Japanese string in UTF-8
$string_mb = "日本語テキストです。01234。";
echo "\n-- ASCII string --\n";
var_dump(mb_strstr($string_ascii, '', false, 'ISO-8859-1'));
var_dump(mb_strstr($string_ascii, ''));
var_dump(mb_strstr($string_ascii, '', true));
echo "\n-- Multibyte string --\n";
var_dump(mb_strstr($string_mb, ''));
var_dump(mb_strstr($string_mb, '', false, 'utf-8'));
var_dump(mb_strstr($string_mb, '', true));
?>
--EXPECT--
-- ASCII string --
string(7) "abc def"
string(7) "abc def"
string(0) ""
-- Multibyte string --
string(53) "日本語テキストです。01234。"
string(53) "日本語テキストです。01234。"
string(0) ""