Imaulle Posted April 21, 2010 Share Posted April 21, 2010 $fh = fopen($url, 'r'); while (!feof($fh)) { $swfaddress_content .= fgets($fh, 4096); } fclose($fh); Hello, the above code is basically causing an infinite loop/server crash. Is there a better way to do this? using cURL or something? or must I enable allow_url_fopen thanks, you guys rock! Quote Link to comment https://forums.phpfreaks.com/topic/199207-allow_url_fopen-or-curl/ Share on other sites More sharing options...
cags Posted April 21, 2010 Share Posted April 21, 2010 If it's not disabled by the server then using file_get_contents would be the simplest solution. Alternatively you could use cURL, it wouldn't need to be too complex. $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $content = curl_exec($curl); Quote Link to comment https://forums.phpfreaks.com/topic/199207-allow_url_fopen-or-curl/#findComment-1045794 Share on other sites More sharing options...
Imaulle Posted April 21, 2010 Author Share Posted April 21, 2010 hmmm. I wanna do the simplest solution! how would I do it with file_get_contents() Quote Link to comment https://forums.phpfreaks.com/topic/199207-allow_url_fopen-or-curl/#findComment-1046149 Share on other sites More sharing options...
oni-kun Posted April 21, 2010 Share Posted April 21, 2010 $content = file_get_contents($url); Quote Link to comment https://forums.phpfreaks.com/topic/199207-allow_url_fopen-or-curl/#findComment-1046150 Share on other sites More sharing options...
Imaulle Posted April 21, 2010 Author Share Posted April 21, 2010 that seems way too easy... testing it now haha. thanks Quote Link to comment https://forums.phpfreaks.com/topic/199207-allow_url_fopen-or-curl/#findComment-1046162 Share on other sites More sharing options...
Imaulle Posted April 22, 2010 Author Share Posted April 22, 2010 errr it seems to be working haha. but that seems way too easy!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/199207-allow_url_fopen-or-curl/#findComment-1046171 Share on other sites More sharing options...
oni-kun Posted April 22, 2010 Share Posted April 22, 2010 errr it seems to be working haha. but that seems way too easy!!!!! Yeah, PHP get a +1 for including atleast one simplified function to pull data without manual socket traversing. Quote Link to comment https://forums.phpfreaks.com/topic/199207-allow_url_fopen-or-curl/#findComment-1046175 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.