KB: PHP file_get_contents() Function and Socket Connections
This article clarifies the use of the file_get_contents() function and explains the limitations on socket connections for free and premium hosting plans.
file_get_contents() Support
The PHP function file_get_contents() is fully supported on free hosting. You can use this function to read the contents of a local file or a remote file from a URL. It's a convenient and popular way to fetch data from other websites or APIs.
Socket Connection Limits
When you use file_get_contents() to retrieve data from a remote URL, it initiates a socket connection. There are specific limits on how many of these connections you can make, especially on free hosting.
Free Hosting: There is an advisory limit of 10,000 PHP socket connections per day on the free hosting plan. If your website or script exceeds this limit, you may encounter errors. This limit is in place to ensure fair usage of server resources.
Premium Hosting: Upgrading to a premium hosting plan removes this restriction. On premium plans, you have unlimited PHP socket connections, which is ideal for websites or applications that require frequent and extensive data fetching from external sources.