0

i have this code which works fine

$done_getting = file_get_contents($url);

if($done_getting == !null) {
    return $done_getting;
} else { 
    return $custom_error_msg;
}

if i'm online it fetches $url and displays well on page, but in the event of a slow internet connection or I am offline I get

Warning: file_get_contents(url ): failed to open stream: HTTP request failed! in xxxxxx

This is the correct error msg from php , how do i customise this msg instead of getting this one as it tells the user were my root files are.

Is it possible to customise it.

I am using this in wordpress(debug mode). the code above works too, so when there is an error it returns $custom_error_msg but only after showing the default php error.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user1951739
  • 135
  • 1
  • 9
  • 1
    Did you search? http://stackoverflow.com/questions/272361/how-can-i-handle-the-warning-of-file-get-contents-function-in-php – Amal Murali Aug 28 '13 at 13:50
  • In production the warnings and errors should be off. But still fix the issue :) – Mattt Aug 28 '13 at 13:55
  • Actually the errors and warnings should be on only logged instead of displayed. :-) `` – PeeHaa Aug 28 '13 at 13:56
  • you are right, in production it does not show save for my custom error, the problem being that its a plugin i'm working on and will eventually give up location of my directories – user1951739 Aug 28 '13 at 14:25
  • @Amal Murali , i think thats the solution , will test now – user1951739 Aug 28 '13 at 14:28

0 Answers0