#43994 [Opn->Asn]: mb_ereg 'successfully' matching incorrectly

From: Date: Thu, 31 Jan 2008 17:06:05 +0000
Subject: #43994 [Opn->Asn]: mb_ereg 'successfully' matching incorrectly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121834@lists.php.net to get a copy of this message
ID: 43994 Updated by: nicholsr@php.net Reported By: josmessa at uk dot ibm dot com -Status: Open +Status: Assigned Bug Type: mbstring related Operating System: Windows XP SP2 PHP Version: 5.2CVS-2008-01-31 (snap) -Assigned To: +Assigned To: hirokawa New Comment: Assign to extension maintainer Previous Comments: ------------------------------------------------------------------------ [2008-01-31 15:04:31] josmessa at uk dot ibm dot com Description: ------------ When mb_ereg is passed certain data types as the $pattern argument it will return int(1), i.e. a successful match, when in fact it has not matched. This is shown by setting the $regs argument and looking at the returned array which only contains one element which is bool(false). Reproduce code: --------------- <?php $unset_var = 10; unset ($unset_var); $inputs = array(NULL, null, false, FALSE, "", '', @$undefined_var, @$unset_var); $iterator = 1; foreach($inputs as $input) { if(@is_array($mb_regs)){ $mb_regs = ''; } echo "\n-- Iteration $iterator --\n"; echo "Without \$regs arg:\n"; var_dump( mb_ereg($input, 'hello, world') ); echo "With \$regs arg:\n"; var_dump(mb_ereg($input, 'hello, world', $mb_regs)); var_dump($mb_regs); $iterator++; }; ?> Expected result: ---------------- http://pastebin.com/f5f5c20ff Actual result: -------------- http://pastebin.com/f3f966bd0 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43994&edit=1

« previous php.bugs (#121834) next »