PDA

View Full Version : Including a page from a different server using php


WA
08-13-2002, 05:30 AM
Does anyone the limitations of using PHP to read a page from another server and display on the current? For example, I find that the code:


<?
$url="http://www.yahoo.com/";
$test=readfile($url);
?>

works on one server in extracting and showing Yahoo's page, while on another server, it doesn't work. Does it have to do with safe mode, or something else? Why the inconsistency?

Thanks,

Spookster
08-13-2002, 06:06 AM
What does it do when it doesn't work? Any error messages or warnings?

Probably has to do with safe mode.

http://www.php.net/manual/en/features.safe-mode.php

WA
08-13-2002, 07:59 AM
Thanks Spookster. In the error case no message was displayed. I guess the web host supressed it.

The thing is, I've always thought it wasn't possible to use php to include/display a page that's not on the same server as the script is on. Guess I was wrong...

Spookster
08-13-2002, 07:40 PM
You can include files from other servers whether is it http, ftp, etc. You can also grab source code from remote files:

http://www.php.net/manual/en/function.file-get-contents.php

Useful for things like stock tickers, news headlines, etc.