これを行うには多くの方法がありますが、1つの方法はSOAPクライアント/サーバーソリューションです。
基本的に2つのphpファイルがあります。server1の1つのファイルはclient.phpで、もう1つのサーバーにはserver.phpという名前のファイルがあり、サーバー1のclient.phpから送信されたすべてのデータを受信します...ここにあります単純なソースの場合、スクリプト内のURLをサーバー/クライアントのURLに変更して、機能させる必要があります。
client.php
<?php
//This is the SOAP Client which will call a method on Server 2 with passing some data:
//uri is the location where client.php is located, and "location" is the exact location to the client, including the name "client.php"
$client=new SoapClient(NULL,array("uri"=>"http://localhost/test","location"=>"http://localhost/test/test.php"));
$message=$client->hello("Hello World");
echo($message);
?>
server.php
<?php
//This is the SOAP Server
class server2{
public function hello($data){
return "I received following data: " . $data;
}
}
//the URI here is the location where the server.php is located.
$settings = array("uri"=>"http://localhost/test/");
$s=new SoapServer(null,$settings);
$s->setClass("server2");
$s->handle();
?>