Welcome Guest, Not a member yet? Register   Sign In
Is this ok? Suppressing warnings with the @ symbol
#1

(This post was last modified: 08-09-2016, 08:55 AM by PaulD.)

Hi,

Having just discovered get_meta_tags and dumping all my CURL functions a problem arose. During user testing some URLS (trimmed, properly validated, working and perfectly normal urls) were throwing an error. The function was called in an ajax call and the warning was displaying in the message field (normally used for 'Invalid URL' or 'Name too long' type error messages or 'Thanks, that site has been added' messages).

It seems that even with a TRY and CATCH error catching the warning was still coming through. It appears that the get_meta_tags, which returns FALSE on failure anyway, insists on throwing the warning for URL's it does not like for some reason or because the target server is simply not allowing that sort of request.

So, to stop it doing it, I just added an @ in front of the function call.

PHP Code:
$tags = @get_meta_tags($url); 

It works, but a few forums have been saying things like 'Don't use this' or 'Beware this approach as it can cause problems' etc.

This is not something I would normally do, but I cannot think of what else to do with this function. (Apart from going back to my much longer, slower but more predictable CURL functions again).

If anyone has an opinion or any ideas about this, they would be very much appreciated.

Best wishes,

Paul.
Reply


Messages In This Thread
Is this ok? Suppressing warnings with the @ symbol - by PaulD - 08-09-2016, 08:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB