global statement removal: hphp/test/zend [2/x]
[hiphop-php.git] / hphp / test / zend / good / ext / iconv / tests / iconv_strpos_variation5.php
blob09b87065d5f0cb7f69e93db2904f7cc05d5f3030
1 <?php
2 /* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]])
3 * Description: Find position of first occurrence of a string within another
4 * Source code: ext/iconv/iconv.c
5 */
7 /*
8 * Test how iconv_strpos() behaves when passed different integers as $offset argument
9 * The character length of $string_ascii and $string_mb is the same,
10 * and the needle appears at the same positions in both strings
13 iconv_set_encoding("internal_encoding", "UTF-8");
15 echo "*** Testing iconv_strpos() : usage variations ***\n";
17 $string_ascii = b'+Is an English string'; //21 chars
18 $needle_ascii = b'g';
20 $string_mb = base64_decode(b'5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); //21 chars
21 $needle_mb = base64_decode(b'44CC');
24 * Loop through integers as multiples of ten for $offset argument
25 * iconv_strpos should not be able to accept negative values as $offset.
26 * 60 is larger than *BYTE* count for $string_mb
28 for ($i = -10; $i <= 60; $i += 10) {
29 echo "\n**-- Offset is: $i --**\n";
30 echo "-- ASCII String --\n";
31 var_dump(iconv_strpos($string_ascii, $needle_ascii, $i));
32 echo "--Multibyte String --\n";
33 var_dump(iconv_strpos($string_mb, $needle_mb, $i, 'UTF-8'));
36 echo "Done";