xref: /PHP-8.0/ext/mbstring/tests/mb_strstr.phpt (revision f8d79582)
1--TEST--
2mb_strstr()
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--FILE--
6<?php
7function EUC_JP($utf8str) {
8    return mb_convert_encoding($utf8str, "EUC-JP", "UTF-8");
9}
10
11function FROM_EUC_JP($eucjpstr) {
12    return mb_convert_encoding($eucjpstr, "UTF-8", "EUC-JP");
13}
14
15var_dump(mb_strstr("あいうえおかきくけこ", "おかき"));
16var_dump(mb_strstr("あいうえおかきくけこ", "おかき", false));
17var_dump(mb_strstr("あいうえおかきくけこ", "おかき", true));
18var_dump(FROM_EUC_JP(mb_strstr(EUC_JP("あいうえおかきくけこ"), EUC_JP("おかき"), false, "EUC-JP")));
19var_dump(FROM_EUC_JP(mb_strstr(EUC_JP("あいうえおかきくけこ"), EUC_JP("おかき"), true, "EUC-JP")));
20mb_internal_encoding("EUC-JP");
21var_dump(FROM_EUC_JP(mb_strstr(EUC_JP("あいうえおかきくけこ"), EUC_JP("おかき"))));
22var_dump(FROM_EUC_JP(mb_strstr(EUC_JP("あいうえおかきくけこ"), EUC_JP("おかき"), false)));
23var_dump(FROM_EUC_JP(mb_strstr(EUC_JP("あいうえおかきくけこ"), EUC_JP("おかき"), true)));
24?>
25--EXPECT--
26string(18) "おかきくけこ"
27string(18) "おかきくけこ"
28string(12) "あいうえ"
29string(18) "おかきくけこ"
30string(12) "あいうえ"
31string(18) "おかきくけこ"
32string(18) "おかきくけこ"
33string(12) "あいうえ"
34