1--TEST--
2Test iconv_strpos() function : basic functionality
3--SKIPIF--
4<?php
5extension_loaded('iconv') or die('skip');
6function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build");
7?>
8--INI--
9error_reporting=E_ALL & ~E_DEPRECATED
10--FILE--
11<?php
12/* Prototype  : int iconv_strpos(string haystack, string needle [, int offset [, string charset]])
13 * Description: Find position of first occurrence of a string within another
14 * Source code: ext/iconv/iconv.c
15 */
16
17/*
18 * Test basic functionality of iconv_strpos with ASCII and multibyte characters
19 */
20
21echo "*** Testing iconv_strpos() : basic functionality***\n";
22
23iconv_set_encoding("internal_encoding", "UTF-8");
24
25$string_ascii = 'abc def';
26//Japanese string in UTF-8
27$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
28
29echo "\n-- ASCII string 1 --\n";
30var_dump(iconv_strpos($string_ascii, 'd', 2, 'ISO-8859-1'));
31
32echo "\n-- ASCII string 2 --\n";
33var_dump(iconv_strpos($string_ascii, '123'));
34
35echo "\n-- Multibyte string 1 --\n";
36$needle1 = base64_decode('5pel5pys6Kqe');
37var_dump(iconv_strpos($string_mb, $needle1));
38
39echo "\n-- Multibyte string 2 --\n";
40$needle2 = base64_decode("44GT44KT44Gr44Gh44Gv44CB5LiW55WM");
41var_dump(iconv_strpos($string_mb, $needle2));
42
43echo "Done";
44?>
45--EXPECTF--
46*** Testing iconv_strpos() : basic functionality***
47
48-- ASCII string 1 --
49int(4)
50
51-- ASCII string 2 --
52bool(false)
53
54-- Multibyte string 1 --
55int(0)
56
57-- Multibyte string 2 --
58bool(false)
59Done
60