1--TEST-- 2mb_ereg_search_setpos() function 3--SKIPIF-- 4<?php 5if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); 6if (!function_exists("mb_regex_encoding")) die("skip mb_regex_encoding() is not defined"); 7?> 8--FILE-- 9<?php 10mb_regex_encoding('iso-8859-1'); 11$test_str = 'I�t�rn�ti�n�liz�ti�n'; // Length = 20 12 13var_dump(mb_ereg_search_setpos(50)); // OK 14var_dump(mb_ereg_search_setpos(-1)); // Error 15 16mb_ereg_search_init($test_str); 17 18$positions = array( 5, 20, 21, 25, 0, -5, -20, -30); 19foreach($positions as $pos) { 20 echo("\n* Position: $pos :\n"); 21 var_dump(mb_ereg_search_setpos($pos)); 22 var_dump(mb_ereg_search_getpos()); 23} 24?> 25==DONE== 26--EXPECTF-- 27bool(true) 28 29Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d 30bool(false) 31 32* Position: 5 : 33bool(true) 34int(5) 35 36* Position: 20 : 37bool(true) 38int(20) 39 40* Position: 21 : 41 42Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d 43bool(false) 44int(0) 45 46* Position: 25 : 47 48Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d 49bool(false) 50int(0) 51 52* Position: 0 : 53bool(true) 54int(0) 55 56* Position: -5 : 57bool(true) 58int(15) 59 60* Position: -20 : 61bool(true) 62int(0) 63 64* Position: -30 : 65 66Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d 67bool(false) 68int(0) 69==DONE== 70