Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Author Message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sat Feb 21, 2004 12:45 am Reply with quote

file_get_contents() is a great tool for reading a file, whether local or from another site. In its truest form you can do this
$content = file_get_contents('http://yahoo.com');

Now you have the entire home page of yahoo in a variable ($content) and you can do whatever you want with it and then display it with an echo statement. But, you must be running PHP v4.3 or greater or it errors out. Here is a function that you can place in your code to fix that. I found this a while back at php.net while investigating some issues with the function.
Code:
if (!function_exists("file_get_contents")) { 

  function file_get_contents($filename, $use_include_path = 0) {
   $data = FALSE;
   $file = fopen($filename, "rb", $use_include_path);
   if ($file) {
     while (!feof($file)) $data .= fread($file, 1024);
     fclose($file);
   }
   return $data;
  }
}
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©