At Sun, 10 Jun 2007 05:36:11 -0700, Sergei Shelukhin let h(is|er) monkeys
type:
Hi.
I need to handle warnings in incorrect regular expressions executed
using preg_match.
Warnings shouldn't appear, instead I want to output some generic
message like: "Bad regex: $regex" and also do a database change.
I tried using try-catch but warnings are not caught.
What do I do?
You can suppress warnings by setting the proper error_reporting() level
(see manual), or by prepending your function call with @.
Then check for the returned value by the regex function and use
trigger_error('Your message',E_USER_WARNING). (Again, see manual for
details)
if (! @preg_match($pattern,$string,$match_arr) {
trigger_error ('Blahblah', E_USER_WARNING);
}
--
Schraalhans Keukenmeester -
sc*********@the.Spamtrapexample.nl
[Remove the lowercase part of Spamtrap to send me a message]
"strcmp('apples','oranges') < 0"