Reply to Re: handling warnings, php5?

Your name:

Reply:


Posted by Schraalhans Keukenmeester on 06/10/07 14:10

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 - schraalhans@the.Spamtrapexample.nl
[Remove the lowercase part of Spamtrap to send me a message]

"strcmp('apples','oranges') < 0"

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация