Re: Suppressing error from displaying
| From: | Thiago H. Pojda | Date: | Wed, 24 Nov 2010 19:17:31 +0000 |
| Subject: | Re: Suppressing error from displaying | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309651@lists.php.net to get a copy of this message | ||
On Wed, Nov 24, 2010 at 5:13 PM, Ron Piggott <ron.piggott@actsministries.org
> wrote:
>
> I am using this syntax to check for a valid e-mail address
>
> list($userName, $mailDomain) = split("@", $buyer_email);
> if (checkdnsrr($mailDomain, "MX")) {
>
> if no domain is provided ( ie e-mail address is something like “ron” with
> no @ ) the following error is displayed:
>
> Warning: checkdnsrr() [function.checkdnsrr]: Host and type cannot be empty
>
> Can I suppress this from displaying so *just* my error message displays?
>
> Ron
>
Just add @ before checkdnsrr:
list($userName, $mailDomain) = split("@", $buyer_email);
if (@checkdnsrr($mailDomain, "MX")) {
But you shouldn't use @ as it will make a PITA to find errors in your code
when maintaining it. You should not display Warnings on production too, at
least not for users but instead log those.
Cheers,
Thiago Pojda