Like many others I’ve used the native PHP function file_get_contents() to receive the content from a remote file because the functions is very easy to use. But is it the best way to do that? I see many scripts using that function and even WordPress plugins are using this function while WordPress has a native function to receive remote content.
While debugging some website, I’ve noticed that I get trouble using file_get_contents() if I use the 5G firewall rules for the remote site I tried to access. This native PHP function doesn’t send any USER AGENT information and that’s why a 5G rules has blocked the access. There are also other reasons to use other functions: Missing response codes, no option to add additional headers and limitations from your hosting provider are just a view of them. Continue reading Alternative functions for file_get_contents()