1--TEST--
2Test mb_strpos() function : basic functionality
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip');
6function_exists('mb_strpos') or die("skip mb_strpos() is not available in this build");
7?>
8--FILE--
9<?php
10/*
11 * Test basic functionality of mb_strpos with ASCII and multibyte characters
12 */
13
14echo "*** Testing mb_strpos() : basic functionality***\n";
15
16mb_internal_encoding('UTF-8');
17
18$string_ascii = 'abc def';
19//Japanese string in UTF-8
20$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
21
22echo "\n-- ASCII string 1 --\n";
23var_dump(mb_strpos($string_ascii, 'd', 2, 'ISO-8859-1'));
24
25echo "\n-- ASCII string 2 --\n";
26var_dump(mb_strpos($string_ascii, '123'));
27
28echo "\n-- Multibyte string 1 --\n";
29$needle1 = base64_decode('5pel5pys6Kqe');
30var_dump(mb_strpos($string_mb, $needle1));
31
32echo "\n-- Multibyte string 2 --\n";
33$needle2 = base64_decode("44GT44KT44Gr44Gh44Gv44CB5LiW55WM");
34var_dump(mb_strpos($string_mb, $needle2));
35
36echo "Done";
37?>
38--EXPECT--
39*** Testing mb_strpos() : basic functionality***
40
41-- ASCII string 1 --
42int(4)
43
44-- ASCII string 2 --
45bool(false)
46
47-- Multibyte string 1 --
48int(0)
49
50-- Multibyte string 2 --
51bool(false)
52Done
53