andyfarang Posted March 24, 2016 Share Posted March 24, 2016 I'm using get_file_content and sometimes I get failed to open stream http, which isn't a problem, but displaying that message is a problem. Can I turn it off (in a script, not in php.ini etc.)? Quote Link to comment https://forums.phpfreaks.com/topic/301077-turn-off-error-message-at-get_file_content/ Share on other sites More sharing options...
Solution Jacques1 Posted March 24, 2016 Solution Share Posted March 24, 2016 (edited) There's the error suppression operator. Whether that's a good idea is debatable, though, because it will suppress all errors, including serious ones. Consider using a more professional HTTP client like cURL. Edited March 24, 2016 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/301077-turn-off-error-message-at-get_file_content/#findComment-1532418 Share on other sites More sharing options...
andyfarang Posted March 24, 2016 Author Share Posted March 24, 2016 (edited) There's the error suppression operator. Whether that's a good idea is debatable, though, because it will suppress all errors, including serious ones. Consider using a more professional HTTP client like cURL. Thank you. SOLVED Edited March 24, 2016 by andyfarang Quote Link to comment https://forums.phpfreaks.com/topic/301077-turn-off-error-message-at-get_file_content/#findComment-1532419 Share on other sites More sharing options...
ginerjm Posted March 24, 2016 Share Posted March 24, 2016 Perhaps instead of suppressing the error you trap for a False result and either then ignore it or display a short message to the user? if (fopen($filename) === False) { $err_message = "Could not open file: $filename"; // include this var in your final output // decide here whether to continue on or not } // at this point you have successfully opened it. Just my $.02. Quote Link to comment https://forums.phpfreaks.com/topic/301077-turn-off-error-message-at-get_file_content/#findComment-1532421 Share on other sites More sharing options...
Jacques1 Posted March 24, 2016 Share Posted March 24, 2016 This is about the HTTP stream wrapper which automatically emits warnings when there's an HTTP-related problem. It's not possible to catch those errors (except for hacks like a temporary error handler). Quote Link to comment https://forums.phpfreaks.com/topic/301077-turn-off-error-message-at-get_file_content/#findComment-1532422 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.