Forum Moderators: coopster

Message Too Old, No Replies

how can i include a remote url

         

lindajames

3:56 am on Dec 3, 2004 (gmt 0)

10+ Year Member



I am currently including a remote URL like this:

<?php
include("http://www.yahoo.com");
?>

but the problem is that the place i want to include it is inside a variable which is:

$content='

HTML Content Goes here

';

can anyone tell me how i can include the remote page within the $content variable.

thank you

Robber

9:31 am on Dec 3, 2004 (gmt 0)

10+ Year Member



Could do this without using include - take a look at fsockopen and fgets, you can use these to read file at the URL you are using and storing it in a variable, just like reading a local file really.

mincklerstraat

12:21 pm on Dec 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



or just
$content = file_get_contents('ht*p://example.com');

baze22

12:23 pm on Dec 3, 2004 (gmt 0)

10+ Year Member



This works too:

$file= "http://www.yahoo.com"; 
if($data = file_get_contents($file)){
echo $data;
} else {
echo "No data to echo";
}

baze