Problem Description
I need to catch some warnings being thrown from some php native functions and then handle them.
Specifically:
array dns_get_record ( string $hostname [, int $type= DNS_ANY [, array &$authns [, array &$addtl ]]] )
It throws a warning when the DNS query fails.
`try`/`catch` doesn't work because a warning is not an exception.
I now have 2 options:
1. `set_error_handler` seems like overkill because I have to use it to filter every warning in the page (is this true?);
2. Adjust error reporting/display so these warnings don't get echoed to screen, then check the return value; if it's `false`, no records is found for hostname.
What's the best practice here?
AI-Generated Solution
Powered by LMSouq AI · GPT-4.1-mini
Analyzing problem and generating solution…
Was this solution helpful?