1--TEST-- 2Test mb_strripos() function : usage variations - Pass different integers as $offset argument 3--EXTENSIONS-- 4mbstring 5--FILE-- 6<?php 7/* 8 * Test how mb_strripos() 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 11 */ 12 13mb_internal_encoding('UTF-8'); 14 15echo "*** Testing mb_strripos() : usage variations ***\n"; 16 17$string_ascii = '+Is an English string'; //21 chars 18$needle_ascii = 'G'; 19 20$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); //21 chars 21$needle_mb = base64_decode('44CC'); 22 23/* 24 * Loop through integers as multiples of ten for $offset argument 25 * mb_strripos should not be able to accept negative values as $offset. 26 * 60 is larger than *BYTE* count for $string_mb 27 */ 28for ($i = -10; $i <= 60; $i += 10) { 29 echo "\n**-- Offset is: $i --**\n"; 30 echo "-- ASCII String --\n"; 31 try { 32 var_dump(mb_strripos($string_ascii, $needle_ascii, $i)); 33 } catch (\ValueError $e) { 34 echo $e->getMessage() . \PHP_EOL; 35 } 36 37 echo "--Multibyte String --\n"; 38 try { 39 var_dump(mb_strripos($string_mb, $needle_mb, $i, 'UTF-8')); 40 } catch (\ValueError $e) { 41 echo $e->getMessage() . \PHP_EOL; 42 } 43} 44 45?> 46--EXPECT-- 47*** Testing mb_strripos() : usage variations *** 48 49**-- Offset is: -10 --** 50-- ASCII String -- 51int(9) 52--Multibyte String -- 53int(9) 54 55**-- Offset is: 0 --** 56-- ASCII String -- 57int(20) 58--Multibyte String -- 59int(20) 60 61**-- Offset is: 10 --** 62-- ASCII String -- 63int(20) 64--Multibyte String -- 65int(20) 66 67**-- Offset is: 20 --** 68-- ASCII String -- 69int(20) 70--Multibyte String -- 71int(20) 72 73**-- Offset is: 30 --** 74-- ASCII String -- 75mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 76--Multibyte String -- 77mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 78 79**-- Offset is: 40 --** 80-- ASCII String -- 81mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 82--Multibyte String -- 83mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 84 85**-- Offset is: 50 --** 86-- ASCII String -- 87mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 88--Multibyte String -- 89mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 90 91**-- Offset is: 60 --** 92-- ASCII String -- 93mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 94--Multibyte String -- 95mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 96