Sr. PHP Programmer Question:

How to connect to a URL in PHP?

Senior PHP Programmer Interview Question
Senior PHP Programmer Interview Question

Answer:

It should also be clear that we will need to somehow be able to connect to a URL and view the contents of the page that the URL points to. What is the best way to do this? Well PHP provides a library called cURL that may already be included in your installation of PHP by default. cURL stands for client URL, and it allows you to connect to a URL and retrieve information from that page - like the HTML content of the page, the HTTP headers and their associated data, etc. You will see the use of cURL in our code below - don't worry if you've never used cURL before, it's fairly easy to understand!


Previous QuestionNext Question
What is the difference between $_GET and $_POST?How can you enable error reporting in PHP?