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 46*** Testing mb_ereg_match() : basic functionality *** 47 48-- ASCII string 1 -- 49bool(true) 50 51-- ASCII string 2 -- 52bool(false) 53 54-- Multibyte string 1 -- 55bool(true) 56 57-- Multibyte string 2 -- 58bool(false) 59Done 60