faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

25 of 38 people (66%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

how do i include a remote file using php

Nov 27th, 2008 02:29
healthy man, dman, Praveen Kumar Kukkapalli, Philip Olson, sanket gupta, http://www.ttnr.org


Simple way is to use file() function
$file_content = file("http://sturly.com/supporters.php");
It will return an array.
More information can be found at http://in2.php.net/file
Check out the following :
    PHP Manual : Chapter 20. Using remote files
    http://www.php.net/manual/features.remote-files.php
Examples exist for both FTP and HTTP Methods.  Also, note the include 
function :
    PHP Manual : Include()
    http://www.php.net/manual/function.include.php
Include can also include remote files although has a few conditions 
such as :
    1. URL fopen wrappers must be enabled (they are by default)
    2. Can't include() remote files when using the windows OS
The above manual entries contain more detailed information on these 
topics and includes links/information about related functions.  Here 
are a few examples :
    include 'http://www.php.net/';
If you need it as a variable, try :
    $remote_site = implode(file('http://www.lsyg.com/'),'');
If you've already opened it with fopen() :
    $fp = fopen('http://www.pmoj.com/','r');
    fpassthru($fp);
http://www.healthdothealth.com
http://www.healthxhealth.com
http://www.mesotheliomainmesothelioma.com
http://www.healthfirewall.com
http://www.flathealth.com
http://www.healthbodyguard.com