Jump to content

include remote php file?


B34ST

Recommended Posts

Hi I was wondering if it was possible to include a php file which is hosted on a different domain?

 

for example i have 2 domains http://www.example.com and http://example2.com i have a php script on example.com which i want to include in another script on example2.com.

 

I tried to just simply include the script:

 

include('http://www.example.com/testscript.php');

 

but this does not seem to work. When I checked the manual it said that this is possible as long as the php version is greater than 4.3.0 (which mine is on both domains) and allow_url_fopen is enabled ehich it is on both domains.

 

am i missing something? or is there another way of doing this?

Link to comment
Share on other sites

i dont know what your talking about but curl reads the page in your page as it is you can use the form of the other site as they are on that site

 

but if you think like use the php code i dont think you can 

Link to comment
Share on other sites

curl still uses http requests which will send the output html i recommend to add a line at the begining of the PHP file like this

 

<?
if( $_SERVER['HTTP_REFERER'] == 'http://example.com')
{
echo file_get_contents($_SERVER['PHP_SELF']);
exit();
}
?>

Link to comment
Share on other sites

You an only include a remote file if the appropriate url wrappers are enabled. On most sahred hosts, these are disabled.

 

Rojay, Prime and Teng... the op doesn't want the output of a php file, but wants to include a remote php file, two different things.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.