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.
Loading...
Related Quiz
- You are debugging a PHP script and a variable is not retaining its value between function calls. What might be the problem and how would you solve it?
- A common practice in PHP file handling is to always close the file after you're done with it using the fclose() function to free up ______.
- In PHP, you can open a file using the fopen() function, which takes the path to the file and the mode as the ______.
- The fopen() function is used to open a file in PHP.
- Which of the following are common uses of arrays in PHP?