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.