You are writing a PHP script and you need to fetch the content of a web page from a given URL. How would you do this using network functions?

  • Use the file_get_contents() function to fetch the content of the web page
  • Use the curl_init() function to establish an HTTP connection to the web page
  • Use the fsockopen() function to establish a socket connection to the web page
  • Use the fetch_web_page() function to retrieve the content of the web page
To fetch the content of a web page from a given URL in PHP, you can use the file_get_contents() function. This function allows you to pass the URL as a parameter and retrieves the content of the web page as a string. For example, $content = file_get_contents($url); fetches the content of the web page from the specified URL and stores it in the $content variable. This 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 *