1--TEST-- 2Test mb_ereg_match() function : basic functionality 3--SKIPIF-- 4<?php 5extension_loaded('mbstring') or die('skip'); 6function_exists('mb_ereg_match') or die("skip mb_ereg_match() is not available in this build"); 7?> 8--FILE-- 9<?php 10/* Prototype : bool mb_ereg_match(string $pattern, string $string [,string $option]) 11 * Description: Regular expression match for multibyte string 12 * Source code: ext/mbstring/php_mbregex.c 13 */ 14 15/* 16 * Test basic functionality of mb_ereg_match 17 */ 18 19mb_internal_encoding('UTF-8'); 20mb_regex_encoding('UTF-8'); 21 22echo "*** Testing mb_ereg_match() : basic functionality ***\n"; 23$string_ascii = b'abc def, 0123456789'; 24$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); 25 26//will return true as pattern matches from start of string 27echo "\n-- ASCII string 1 --\n"; 28var_dump(mb_ereg_match(b'.*def', $string_ascii)); 29 30//will return false as pattern would match half way through string 31echo "\n-- ASCII string 2 --\n"; 32var_dump(mb_ereg_match(b'def', $string_ascii)); 33 34echo "\n-- Multibyte string 1 --\n"; 35$regex1 = base64_decode('5pel5pys6KqeKC4qKT9bMS05XSs='); 36var_dump(mb_ereg_match($regex1, $string_mb, b'i')); 37 38echo "\n-- Multibyte string 2 --\n"; 39$regex2 = base64_decode('5LiW55WM'); 40var_dump(mb_ereg_match($regex2, $string_mb)); 41 42echo "Done"; 43?> 44--EXPECTF-- 45*** Testing mb_ereg_match() : basic functionality *** 46 47-- ASCII string 1 -- 48bool(true) 49 50-- ASCII string 2 -- 51bool(false) 52 53-- Multibyte string 1 -- 54bool(true) 55 56-- Multibyte string 2 -- 57bool(false) 58Done 59