1--TEST-- 2Test mb_ereg() function : mb_ereg 'successfully' matching incorrectly 3--SKIPIF-- 4<?php 5extension_loaded('mbstring') or die('skip'); 6function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build"); 7?> 8--FILE-- 9<?php 10/* 11 * mb_ereg 'successfully' matching incorrectly: 12 * Bug now seems to be fixed - error message is now generated when an 'empty' 13 * pattern is supplied to mb_ereg. Similar error message to ereg(). 14 */ 15 16$unset_var = 10; 17unset ($unset_var); 18$inputs = array(NULL, null, false, FALSE, "", '', @$undefined_var, 19@$unset_var); 20 21$iterator = 1; 22foreach($inputs as $input) { 23 if(@is_array($mb_regs)){ 24 $mb_regs = ''; 25 } 26 echo "\n-- Iteration $iterator --\n"; 27 echo "Without \$regs arg:\n"; 28 try { 29 var_dump( mb_ereg($input, 'hello, world') ); 30 } catch (\ValueError $e) { 31 echo $e->getMessage() . \PHP_EOL; 32 } 33 34 echo "With \$regs arg:\n"; 35 try { 36 var_dump(mb_ereg($input, 'hello, world', $mb_regs)); 37 } catch (\ValueError $e) { 38 echo $e->getMessage() . \PHP_EOL; 39 } 40 41 var_dump($mb_regs); 42 $iterator++; 43}; 44?> 45--EXPECT-- 46-- Iteration 1 -- 47Without $regs arg: 48mb_ereg(): Argument #1 ($pattern) must not be empty 49With $regs arg: 50mb_ereg(): Argument #1 ($pattern) must not be empty 51NULL 52 53-- Iteration 2 -- 54Without $regs arg: 55mb_ereg(): Argument #1 ($pattern) must not be empty 56With $regs arg: 57mb_ereg(): Argument #1 ($pattern) must not be empty 58NULL 59 60-- Iteration 3 -- 61Without $regs arg: 62mb_ereg(): Argument #1 ($pattern) must not be empty 63With $regs arg: 64mb_ereg(): Argument #1 ($pattern) must not be empty 65NULL 66 67-- Iteration 4 -- 68Without $regs arg: 69mb_ereg(): Argument #1 ($pattern) must not be empty 70With $regs arg: 71mb_ereg(): Argument #1 ($pattern) must not be empty 72NULL 73 74-- Iteration 5 -- 75Without $regs arg: 76mb_ereg(): Argument #1 ($pattern) must not be empty 77With $regs arg: 78mb_ereg(): Argument #1 ($pattern) must not be empty 79NULL 80 81-- Iteration 6 -- 82Without $regs arg: 83mb_ereg(): Argument #1 ($pattern) must not be empty 84With $regs arg: 85mb_ereg(): Argument #1 ($pattern) must not be empty 86NULL 87 88-- Iteration 7 -- 89Without $regs arg: 90mb_ereg(): Argument #1 ($pattern) must not be empty 91With $regs arg: 92mb_ereg(): Argument #1 ($pattern) must not be empty 93NULL 94 95-- Iteration 8 -- 96Without $regs arg: 97mb_ereg(): Argument #1 ($pattern) must not be empty 98With $regs arg: 99mb_ereg(): Argument #1 ($pattern) must not be empty 100NULL 101