Read content of file or URL into a string

Read content of file or URL into a string
Two examples on how to read the content coming from an URL or from a local file into a string, using PHP.
1. <?php
2. // Guaranteed to work (but a little slower) method
3. $Content = implode('',file("http://www.geekpedia.com/index.php"));
4. echo $Content;
5. 
6. // Or for PHP 4.3.x or later
7. $Content = file_get_contents("http://www.geekpedia.com/index.php");
8. echo $Content;
9. ?>

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top