phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Web Content: Reading Other Web Page

Tag: web content, web page, file   Category: PHP Basic
post: 28 Apr 2008 read: 154


Web Content Tips - Part 6: You can read web page or source code of web page over HTTP. It is easy, because PHP have file functions can all be used to read remote files, file_get_contents(). All text from remote file will be stored at a variabel. Sample like this:

<?php
$url = "http://localhost:8048/blog/index.php";

$data = file_get_contents($url) or die("Cannot open URL");

echo $data;

?>

Or you want to force browser download:


<?php
$url = "http://localhost:8048/blog/index.php";

header("Content-Type: plain/text");
$data = file_get_contents($url) or die("Cannot open URL");

echo $data;

?>



| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting