1--TEST-- 2Bug #45923 (mb_st[r]ripos() offset not handled correctly) 3--SKIPIF-- 4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> 5--INI-- 6mbstring.internal_encoding=UTF-8 7--FILE-- 8<?php 9 10function section($func, $haystack, $needle) 11{ 12 echo "\n------- $func -----------\n\n"; 13 foreach(array(0, 3, 6, 9, 11, 12, -1, -3, -6, -20) as $offset) { 14 echo "> Offset: $offset\n"; 15 var_dump($func($haystack,$needle,$offset)); 16 } 17} 18 19section('strpos' , "abc abc abc" , "abc"); 20section('mb_strpos' , "●○◆ ●○◆ ●○◆", "●○◆"); 21 22section('stripos' , "abc abc abc" , "abc"); 23section('mb_stripos' , "●○◆ ●○◆ ●○◆", "●○◆"); 24 25section('strrpos' , "abc abc abc" , "abc"); 26section('mb_strrpos' , "●○◆ ●○◆ ●○◆", "●○◆"); 27 28section('strripos' , "abc abc abc" , "abc"); 29section('mb_strripos', "●○◆ ●○◆ ●○◆", "●○◆"); 30?> 31--EXPECTF-- 32------- strpos ----------- 33 34> Offset: 0 35int(0) 36> Offset: 3 37int(4) 38> Offset: 6 39int(8) 40> Offset: 9 41bool(false) 42> Offset: 11 43bool(false) 44> Offset: 12 45 46Warning: strpos(): Offset not contained in string in %s on line %d 47bool(false) 48> Offset: -1 49bool(false) 50> Offset: -3 51int(8) 52> Offset: -6 53int(8) 54> Offset: -20 55 56Warning: strpos(): Offset not contained in string in %s on line %d 57bool(false) 58 59------- mb_strpos ----------- 60 61> Offset: 0 62int(0) 63> Offset: 3 64int(4) 65> Offset: 6 66int(8) 67> Offset: 9 68bool(false) 69> Offset: 11 70bool(false) 71> Offset: 12 72 73Warning: mb_strpos(): Offset not contained in string in %s on line %d 74bool(false) 75> Offset: -1 76bool(false) 77> Offset: -3 78int(8) 79> Offset: -6 80int(8) 81> Offset: -20 82 83Warning: mb_strpos(): Offset not contained in string in %s on line %d 84bool(false) 85 86------- stripos ----------- 87 88> Offset: 0 89int(0) 90> Offset: 3 91int(4) 92> Offset: 6 93int(8) 94> Offset: 9 95bool(false) 96> Offset: 11 97bool(false) 98> Offset: 12 99 100Warning: stripos(): Offset not contained in string in %s on line %d 101bool(false) 102> Offset: -1 103bool(false) 104> Offset: -3 105int(8) 106> Offset: -6 107int(8) 108> Offset: -20 109 110Warning: stripos(): Offset not contained in string in %s on line %d 111bool(false) 112 113------- mb_stripos ----------- 114 115> Offset: 0 116int(0) 117> Offset: 3 118int(4) 119> Offset: 6 120int(8) 121> Offset: 9 122bool(false) 123> Offset: 11 124bool(false) 125> Offset: 12 126 127Warning: mb_stripos(): Offset not contained in string in %s on line %d 128bool(false) 129> Offset: -1 130bool(false) 131> Offset: -3 132int(8) 133> Offset: -6 134int(8) 135> Offset: -20 136 137Warning: mb_stripos(): Offset not contained in string in %s on line %d 138bool(false) 139 140------- strrpos ----------- 141 142> Offset: 0 143int(8) 144> Offset: 3 145int(8) 146> Offset: 6 147int(8) 148> Offset: 9 149bool(false) 150> Offset: 11 151bool(false) 152> Offset: 12 153 154Warning: strrpos(): Offset is greater than the length of haystack string in %s on line %d 155bool(false) 156> Offset: -1 157int(8) 158> Offset: -3 159int(8) 160> Offset: -6 161int(4) 162> Offset: -20 163 164Warning: strrpos(): Offset is greater than the length of haystack string in %s on line %d 165bool(false) 166 167------- mb_strrpos ----------- 168 169> Offset: 0 170int(8) 171> Offset: 3 172int(8) 173> Offset: 6 174int(8) 175> Offset: 9 176bool(false) 177> Offset: 11 178bool(false) 179> Offset: 12 180 181Warning: mb_strrpos(): Offset is greater than the length of haystack string in %s on line %d 182bool(false) 183> Offset: -1 184int(8) 185> Offset: -3 186int(8) 187> Offset: -6 188int(4) 189> Offset: -20 190 191Warning: mb_strrpos(): Offset is greater than the length of haystack string in %s on line %d 192bool(false) 193 194------- strripos ----------- 195 196> Offset: 0 197int(8) 198> Offset: 3 199int(8) 200> Offset: 6 201int(8) 202> Offset: 9 203bool(false) 204> Offset: 11 205bool(false) 206> Offset: 12 207 208Warning: strripos(): Offset is greater than the length of haystack string in %s on line %d 209bool(false) 210> Offset: -1 211int(8) 212> Offset: -3 213int(8) 214> Offset: -6 215int(4) 216> Offset: -20 217 218Warning: strripos(): Offset is greater than the length of haystack string in %s on line %d 219bool(false) 220 221------- mb_strripos ----------- 222 223> Offset: 0 224int(8) 225> Offset: 3 226int(8) 227> Offset: 6 228int(8) 229> Offset: 9 230bool(false) 231> Offset: 11 232bool(false) 233> Offset: 12 234 235Warning: mb_strripos(): Offset is greater than the length of haystack string in %s on line %d 236bool(false) 237> Offset: -1 238int(8) 239> Offset: -3 240int(8) 241> Offset: -6 242int(4) 243> Offset: -20 244 245Warning: mb_strripos(): Offset is greater than the length of haystack string in %s on line %d 246bool(false) 247