2016-01-04 23:31:52 +08:00
|
|
|
|
--TEST--
|
|
|
|
|
mb_ereg_search_setpos() function
|
|
|
|
|
--SKIPIF--
|
|
|
|
|
<?php
|
|
|
|
|
if (!extension_loaded('mbstring')) die('skip mbstring not enabled');
|
|
|
|
|
?>
|
|
|
|
|
--FILE--
|
|
|
|
|
<?php
|
|
|
|
|
mb_regex_encoding('iso-8859-1');
|
|
|
|
|
$test_str = 'I<>t<EFBFBD>rn<72>ti<74>n<EFBFBD>liz<69>ti<74>n'; // Length = 20
|
|
|
|
|
|
|
|
|
|
var_dump(mb_ereg_search_setpos(50)); // OK
|
|
|
|
|
var_dump(mb_ereg_search_setpos(-1)); // Error
|
|
|
|
|
|
|
|
|
|
mb_ereg_search_init($test_str);
|
|
|
|
|
|
2016-07-28 21:35:56 +08:00
|
|
|
|
$positions = array( 5, 20, 21, 25, 0, -5, -20, -30);
|
2016-01-04 23:31:52 +08:00
|
|
|
|
foreach($positions as $pos) {
|
|
|
|
|
echo("\n* Position: $pos :\n");
|
|
|
|
|
var_dump(mb_ereg_search_setpos($pos));
|
|
|
|
|
var_dump(mb_ereg_search_getpos());
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
==DONE==
|
|
|
|
|
--EXPECTF--
|
|
|
|
|
bool(true)
|
|
|
|
|
|
|
|
|
|
Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d
|
|
|
|
|
bool(false)
|
|
|
|
|
|
|
|
|
|
* Position: 5 :
|
|
|
|
|
bool(true)
|
|
|
|
|
int(5)
|
|
|
|
|
|
2016-07-28 21:35:56 +08:00
|
|
|
|
* Position: 20 :
|
2016-01-04 23:31:52 +08:00
|
|
|
|
bool(true)
|
2016-07-28 21:35:56 +08:00
|
|
|
|
int(20)
|
2016-01-04 23:31:52 +08:00
|
|
|
|
|
2016-07-28 21:35:56 +08:00
|
|
|
|
* Position: 21 :
|
2016-01-04 23:31:52 +08:00
|
|
|
|
|
|
|
|
|
Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d
|
|
|
|
|
bool(false)
|
|
|
|
|
int(0)
|
|
|
|
|
|
|
|
|
|
* Position: 25 :
|
|
|
|
|
|
|
|
|
|
Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d
|
|
|
|
|
bool(false)
|
|
|
|
|
int(0)
|
|
|
|
|
|
|
|
|
|
* Position: 0 :
|
|
|
|
|
bool(true)
|
|
|
|
|
int(0)
|
|
|
|
|
|
|
|
|
|
* Position: -5 :
|
|
|
|
|
bool(true)
|
|
|
|
|
int(15)
|
|
|
|
|
|
|
|
|
|
* Position: -20 :
|
|
|
|
|
bool(true)
|
|
|
|
|
int(0)
|
|
|
|
|
|
|
|
|
|
* Position: -30 :
|
|
|
|
|
|
|
|
|
|
Warning: mb_ereg_search_setpos(): Position is out of range in %s on line %d
|
|
|
|
|
bool(false)
|
|
|
|
|
int(0)
|
|
|
|
|
==DONE==
|
|
|
|
|
|
|
|
|
|
|