Ignoring errors in file_get_contents HTTP wrapper?

Viewed 19764

The following code is to query an online thesaurus for a search engine I'm building as a college project, but I'm having problems with file_get_contents "failed to open stream" errors. When I send a word the thesaurus doesn't recognize, it throws up an error. I'm trying to write a piece of code that will ignore the error and just proceed without the information.

$thesaurus_search="http://words.bighugelabs.com/api/2/0089388bb57f/".$this->formatted_query."/php";
$result_thesaurus=file_get_contents($thesaurus_search);

I tried:

if (file_get_contents($thesaurus_search) != NULL)
{ // do stuff }

...but its not working because it still returns some sort of string.

What can I do to handle such cases?

4 Answers
Related