There is a nice set of PHP commands for simple GET and PUT control of file and web content, called filegetcontents and fileputcontents. filegetcontents can retrieve the HTML code from any available URL. You could insert it into your website however you want, save it to a flat file, or parse the data and reuse it. Once you have the remote or local data, you have a huge battery of options to use.
There are two issues to consider carefully. The first is that when you “include” global code, you may not get the correct display of graphics that have local pathways. Graphics with global pathways will display fine. Local pathways can be dynamically filtered and corrected on-the-fly. The second, and more important issue, is security. When a web server allows the inclusion of remote code, it is important to make sure that harmful code cannot be inserted and processed. Make sure to eregi_replace bad code as necessary, or use htmlspecialchars to avoid problems.
<?php echo file_get_contents(‘http://www.apple.com’); ?>
Have questions about PHP for your project? Email us and we’ll post solutions here.