Jump to content

include a file on another domain


trampolinejoe

Recommended Posts

Hello,

 

I have a delivery calculator hosted on URL 1 which hosts the backend for 4 different websites.

 

I want to only have a single delivery calculator because if I want change something across all the sites I would like to change it a single time.

 

I need to be able to access the function kept in that file, I need to include it on other domains.

 

I have tried include"www.myurlname.com/deliveryCalc.php"; but it dosnt seem to work.

 

Can anybody please advice.

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/135889-include-a-file-on-another-domain/
Share on other sites

not sure if this  would work without trying it...but maybe its worth a shot

 

eval ( file_get_contents ( "http://domain.com/phpfile.php" ) );

Requesting a file using the HTTP wrapper will not return the PHP source code but the output of the script. Your code will not work.

ah yes i thought it may. i know for a fact it returns HTML but wasnt sure about if it ran the script or not

 

so maybe you should write your external script to return the values you need in a string using file_get_contents() using echo and then do what you need with the string this end

 

like

 

$result = explode ( "&", file_get_contents ( "http://domain.com/script.php" ) );

 

 

echo $result[0]; // bob

echo $result[1]; // 21

 

 

 

script.php may read:

 

echo "bob&21";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.