Jump to content

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";

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.