Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 942665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:18:37+00:00 2026-05-15T22:18:37+00:00

Can I share PHP code between two servers? For e.g. say I have a

  • 0

Can I share PHP code between two servers? For e.g. say I have a file A.php on server1 and B.php on server2; is there a way to use B.php in A.php? The purpose behind this is to make sure that some code which I don’t want to release publicly sits on my servers and other servers just use it as an when needed.

Let me know if the requirements seem fuzzy, I will try and explain anything unclear.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:18:38+00:00Added an answer on May 15, 2026 at 10:18 pm

    There’s two ways to do this.

    The first one is to do a remote include. You would include a file from a remote server. This will not hide your source code. You could limit access to that IP address, but you are not protecting your code. Besides it is bad practice and potentially insecure so I would very strongly advise against it.

    include 'http://serverb.com/some_file.php';
    

    The other possibility is to use a web service. This means that your remote server provides a service. server1 makes a request to server2, providing it with the data that server2 needs to complete the action. server2 processes the data and generates a response, which is returned to server1. server1 parses the response and does something interesting with it. You can use file_get_contents to do such a request. Ideally you’d serialize the output using json or XML for transmission and easy parsing.

    $response = file_get_contents('http://serverb.com/webservice.php?param1=something&param2=something_else');
    

    Note: Web services are slow, the network is a major bottleneck. So you will have to cache the results or do something similar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can you use shared memory to communicate between php scripts and c program in
how we do basic debugging in PHP ? Can anybody share true horror story
Can someone share their experiences with s#arp architecture. we have decided to follow mvp
Can you share the way you setup your unit test projects within your .net
Can anyone share an efficient code snipper to daemonize a process in python?
I have a daily deal aggregator site and i can't get the Facebook share
I hope someone can help. The following piece of php code (see below) is
We currently have some php code that allows an end user to update records
I'm working on a project with PHP. I was planing to use a file
Please share your favorite application design / design patterns for use in PHP with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.