Skip to content

How to Use file_get_contents Function With a Proxy in PHP

file_get_contents — Reads entire file into a string

This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.

file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.

Note: Change user, pass, proxy and port according to you in the above example.