Introduction
file_get_contents() is deprecated in favor of using the CURL libraries. You will occasionally run accross old code that uses the file_get_contents() that you want to use on servers with the file_get_contents functionality disabled. This shows how to convert from that function to the curl functions.
[edit]
file_get_contents code
$data = file_get_contents($remoteurl);
[edit]
curl code
//Initialize the Curl session
$ch = curl_init();
//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Set the URL
curl_setopt($ch, CURLOPT_URL, $URL);
//Execute the fetch
$data = curl_exec($ch);
//Close the connection
curl_close($ch);
//$data now contains the contents of $URL
Think Different: Your FREE daily tech stories on AI, Data Science, ML, IoT, Cloud, Open Source, Python, Rust, Golang, DevOps, Management & the future of human-machine interaction. All the latest tech, from around the world.
Subscribe to:
Post Comments (Atom)
ETL with Python
Photo by Hyundai Motor Group ETL System and Tools: ETL (Extract, Transform, Load) systems are essential for data integration and analytics...
-
The client want to have a shop where regular customers to be able to see products with their retail price, while Wholesale partners to see t...
-
URL based session management does not only have additional security risks compared to cookie based session management, but it can cause also...
-
I have curated the learning pathway for you to learn Machine Learning and Data Science. You can follow the Google Classroom paths below: E...
-
Widgets and gadgets are small applications that run on your desktop or in your web browser which enable you to keep track of things like the...
-
When developing a Web application, it's standard practice to create a database structure on which server-side code is placed for the lo...
-
IoT (Internet of Things) : IoT refers to the interconnection of everyday objects, devices, and appliances to the internet, allowing them t...
-
Photo by Acharaporn Kamornboonyarush Let's compare MongoDB and InfluxDB by prov...
-
Abstract: A solar tracking system is a device or mechanism designed to orient solar panels, solar collectors, or other solar energy harvest...
-
pic: microsoft Power BI Overview: Power BI is a business analytics tool by Microsoft that allows you to visualize and share insights from ...
-
Photo by Nana Dua Let first recap what is CPU and GPU. Image courtesy: researchgate Central Processing Unit ...
No comments:
Post a Comment