CMNetworx Posted March 2, 2007 Share Posted March 2, 2007 Hello, I am working on a host that does not allow fopen, which I have been able to work around for quite a few things, but here is one im getting hung up on.. The Fopen usage went like this function RockPaperScissors($URL) $this->URL = $URL; $this->initURL(); $f = fopen($URL, "r"); if($f) while($pre = fread($f, 1000)) $this->source = $this->source.$pre; else { echo 'Unable to open '.$URL.'.'; return false; } } Now, I am trying this in Curl, but Im doing something wrong, The Fopen outputs the information in a while statement $this->source = $this->source.$pre; How do I do this in curl? Here is how far I am.. function RockPaperScissors($URL) { $c = curl_init($URL); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); $f = curl_exec($c); curl_close($c); if($f) return $f; else { echo 'Unable to open '.$URL.'.'; return false; } } but I know thats not right, because the script is expecting it to return in $this>format How do I do that? Any help would be appreciated. Link to comment https://forums.phpfreaks.com/topic/40801-changing-from-fopen-to-curl/ Share on other sites More sharing options...
fert Posted March 2, 2007 Share Posted March 2, 2007 but I know thats not right, because the script is expecting it to return in $this>format How do I do that? Put it in a class Link to comment https://forums.phpfreaks.com/topic/40801-changing-from-fopen-to-curl/#findComment-197548 Share on other sites More sharing options...
CMNetworx Posted March 2, 2007 Author Share Posted March 2, 2007 well, There is already a class in the script class Info { var $name = 'N/A'; // Name of the theater var $address = 'N/A'; // Address line one of the theater var $mapItURL = 'N/A'; // Map it URL, to display the yahoo map of the theater location var $infoURL = 'N/A'; // "Theater Info" link URL I just don't know how to take the curl response and put it in there.. It looks like the fopen was just grabbing the first 1000 bytes? Link to comment https://forums.phpfreaks.com/topic/40801-changing-from-fopen-to-curl/#findComment-197552 Share on other sites More sharing options...
CMNetworx Posted March 2, 2007 Author Share Posted March 2, 2007 Im guessing it would be something like this?? function RockPaperScissors($URL) { $c = curl_init($URL); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); $f = curl_exec($c); curl_close($c); if($f) while($pre = curl_exec($c, 1000)) $this->source = $this->source.$pre; else { echo 'Unable to open '.$URL.'.'; return false; } } Im not sure if that is right.. Anyone else dealt with this? Link to comment https://forums.phpfreaks.com/topic/40801-changing-from-fopen-to-curl/#findComment-197618 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.