Annotation of embedaddon/php/ext/mbstring/tests/mb_strrchr_variation5.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test mb_strrchr() function : variation - multiple needles
! 3: --SKIPIF--
! 4: <?php
! 5: extension_loaded('mbstring') or die('skip');
! 6: function_exists('mb_strrchr') or die("skip mb_strrchr() is not available in this build");
! 7: ?>
! 8: --FILE--
! 9: <?php
! 10: /* Prototype : string mb_strrchr(string haystack, string needle[, bool part[, string encoding]])
! 11: * Description: Finds the last occurrence of a character in a string within another
! 12: * Source code: ext/mbstring/mbstring.c
! 13: * Alias to functions:
! 14: */
! 15:
! 16: echo "*** Testing mb_strrchr() : variation ***\n";
! 17:
! 18: mb_internal_encoding('UTF-8');
! 19:
! 20: //with repeated needles
! 21: $string_ascii = b'abcdef zbcdyx';
! 22: $needle_ascii = b"bcd";
! 23:
! 24: //Japanese string in UTF-8 with repeated needles
! 25: $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OIMzTvvJXvvJbml6XmnKzoqp7jg4bjgq3jgrnjg4g=');
! 26: $needle_mb = base64_decode('6Kqe44OG44Kt');
! 27:
! 28: echo "-- Ascii data --\n";
! 29: var_dump(bin2hex(mb_strrchr($string_ascii, $needle_ascii, false)));
! 30: var_dump(bin2hex(mb_strrchr($string_ascii, $needle_ascii, true)));
! 31:
! 32: echo "-- mb data in utf-8 --\n";
! 33: $res = mb_strrchr($string_mb, $needle_mb, false);
! 34: if ($res !== false) {
! 35: var_dump(bin2hex($res));
! 36: }
! 37: else {
! 38: echo "nothing found!\n";
! 39: }
! 40: $res = mb_strrchr($string_mb, $needle_mb, true);
! 41: if ($res !== false) {
! 42: var_dump(bin2hex($res));
! 43: }
! 44: else {
! 45: echo "nothing found!\n";
! 46: }
! 47:
! 48:
! 49: ?>
! 50: ===DONE===
! 51: --EXPECT--
! 52: *** Testing mb_strrchr() : variation ***
! 53: -- Ascii data --
! 54: string(10) "6263647978"
! 55: string(16) "616263646566207a"
! 56: -- mb data in utf-8 --
! 57: string(30) "e8aa9ee38386e382ade382b9e38388"
! 58: string(70) "e697a5e69cace8aa9ee38386e382ade382b9e383883334efbc95efbc96e697a5e69cac"
! 59: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>