What function do you use in PHP to establish an HTTP connection and fetch the content of a web page?

  • file_get_contents()
  • curl_exec()
  • fopen()
  • All of the above
In PHP, you can establish an HTTP connection and fetch the content of a web page using the file_get_contents() function. This function allows you to retrieve the contents of a file or URL and returns the content as a string. By providing a URL as the parameter, you can establish an HTTP connection and fetch the HTML content of a web page. Additionally, you can use this function with various options and stream contexts to handle different scenarios, such as setting HTTP headers or sending POST data. The file_get_contents() function provides a simple way to retrieve web page content in PHP.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *