0

I'm not sure it is possible or not, but i try include "http://www.abc.cm.my/function.php" inside my php file and it not work.

my ideal is

i have a standard function file at my own website and all my clients web will include my standard function directly from my own website, then i no need to duplicate the function file to all my clients website, the trouble i facing now is, i need to change/update the function file at each/all of my clients website, it not hard but just many work to do.

hope you guys understand my situation and my English.

user1493339
  • 429
  • 4
  • 15
  • php is processes server-side, so if you tried to call to another website you would only see the rendered result. – serakfalcon Jun 05 '14 at 16:12
  • Look into webservices. JSON, SOAP/XML, etc. – jraede Jun 05 '14 at 16:13
  • possible duplicate of [including a remote file in PHP](http://stackoverflow.com/questions/1158348/including-a-remote-file-in-php) – felipsmartins Jun 05 '14 at 16:14
  • thanks guy, it call 'remote file' – user1493339 Jun 05 '14 at 16:22
  • it is never a good idea to do remote file inclusion, there is an inherant massive security risk with enabling this feature across the internet, if you HAVE to do this, you should setup a VPN for secure network access. Otherwise you should really just create an API service to run remotely and return results. – RaggaMuffin-420 Jun 05 '14 at 16:39
  • Dear RaggaMuffin, i'm just a PHP developer can you provide me any website about this, i'm sure if i google [API service] it come out many different info, but sure i will google it as well, thanks – user1493339 Jun 06 '14 at 02:44

2 Answers2

0

Sure, you can use the URL include wrappers option in PHP on website1. You'll need to make sure that the remote server (website2) is serving the raw PHP--so that when you open it in a browser at http://website1/script.php you see the plain PHP source code.

However this is generally a bad idea, since you normally only want the PHP to be visible server-side (normally you don't want to show your raw code to the world). You could use network mappings / mounts to map the remote filesystem to a local drive, or it would be a bit better if website2 were only a LAN only visible to website1.

STW
  • 44,917
  • 17
  • 105
  • 161
0

PHP allows for this under certain conditions:

... URLs can be used with the include, include_once, require and require_once statements (since PHP 5.2.0, allow_url_include must be enabled for these) ...

Doc

marekful
  • 14,986
  • 6
  • 37
  • 59