php-8.0.30-src/ext/mbstring/tests/mb_stristr_empty_needle.phpt

38 lines
996 B
PHP
Raw Permalink 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_stristr() function : with empty needle
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip');
function_exists('mb_stristr') or die("skip mb_stristr() 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_stristr($string_ascii, '', false, 'ISO-8859-1'));
var_dump(mb_stristr($string_ascii, ''));
var_dump(mb_stristr($string_ascii, '', true));
echo "\n-- Multibyte string --\n";
var_dump(mb_stristr($string_mb, ''));
var_dump(mb_stristr($string_mb, '', false, 'utf-8'));
var_dump(mb_stristr($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) ""