Popular & Trending •
Live Kenyan TV •
Live Kenyan Radio
Follow Us Like Us
PHP: Get the contents of a web page, RSS feed, or XML file into a string variabl
66 people viewed
|PHP: Get the contents of a web page, RSS feed, or XML file into a string variabl by Kenyans247(1): Sun 22, March, 2020 10:52am|
You will often have the need to access data that resides on another server, whether you are writing an online RSS aggregator or doing screen scraping for a searching mechanism. PHP makes pulling this data into a string variable an extremely simple process.
You can go with the really short method:
$url = “https://www.howtogeek.com”;
$str = file_get_contents($url);
The only problem with that method is that some web hosts have url access blocked in the file methods, for security reasons. You may be able to use this workaround method instead:
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
0 Shares 0 Like •
For you to post content on this website you have to log in or register, it only take few minute to create account
Recommended for youWhat Is The Best Thing About The Country Of Nigeria? What Is The Best Thing About The City Of Dar Es Salaam Tanzania? Can Antibiotics Treat The Coronavirus Disease? Can Babies Get The Coronavirus Disease?
Sections: Kenyans247 ads, Africa, Family, K247 Intelligence, Diaspora, Programing, Art, Graphics & Video, Universities, Building/Architecture, Innovation, Gossip, Music/Radio, K247 TV, TV/Movies, Poetry, Burundi Forum, Somalia Forum, Rwanda Forum, South Sudan Forum, Tanzania Forum,
Kenyans247 - Copyright © 2019 - 2020 Sande Kennedy. All rights reserved. See How To Advertise.
Disclaimer: Every Kenyans247 member is solely responsible for anything that he/she posts or uploads on Kenyans247.