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.
Loading...
Related Quiz
- When is a destructor called in a PHP class?
- How can you filter multiple inputs in PHP?
- Which of the following are common uses of associative arrays in PHP?
- The PHP files should be saved with a ______ extension for the server to parse them.
- What are the potential issues with a do...while loop in PHP?