skaterdav85 Posted December 21, 2009 Share Posted December 21, 2009 How do i get my output to hide these warnings and notices? Notice: file_get_contents() [function.file-get-contents]: Unable to find the wrapper "fhttp" - did you forget to enable it when you configured PHP? in /Applications/MAMP/htdocs/php_practice/test.php on line 4Warning: file_get_contents(fhttp://twitter.com/statuses/user_timeline.xml?screen_name=StudentSurvivor&count=2) [function.file-get-contents]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/php_practice/test.php on line 4i purposely messed up $twitter_request as you can see with the 'f' before the 'http://'. The code runs correctly, but displays all these warnings. <?php$twitter_request = "fhttp://twitter./statuses/user_timeline.xml?screen_name=StudentSurvivor&count=2";if(file_get_contents($twitter_request) == FALSE) { echo 'error'; }else { echo 'success';} ?> Link to comment Share on other sites More sharing options...
Synook Posted December 21, 2009 Share Posted December 21, 2009 You can use the error_reporting() function to change the level of error reporting at runtime... but you're not really going to leave the code like that when you release it, are you? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 21, 2009 Share Posted December 21, 2009 You can also use the @ operator with the call to file_get_contents, that will suppress errors from that function. Link to comment Share on other sites More sharing options...
skaterdav85 Posted December 21, 2009 Author Share Posted December 21, 2009 well my original code was to make a rest web web service call to display the tweets for this one twitter account. However, I noticed sometimes, not often though, it wont work, and I'll get warnings. Maybe it's because I was refreshing too much. I guess I could just suppress the errors with @, but ideally I would like to do some kind of error handling so that if an error/warning is detected, the only thing echoed out for this section of the page would be something like "Error connecting to Twitter". Any ideas? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 21, 2009 Share Posted December 21, 2009 It should be fine if you just suppress the error and check if the return from file_get_contents was false, if it was then the connection failed. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.