我想知道是否有办法将数据从一台计算机上打开的index.php
发送到另一台计算机上打开的index.php
。
我不知道该怎么做。
答案 0 :(得分:-1)
是
简单/懒惰:只需执行远程获取请求
// example1.com/index.php
file_get_contents("http://example2.com/index.php?your_data=goes_here");
// example2.com/index.php
$your_data = $_GET['your_data'];
更难/更好方式:使用curl发送帖子请求
// on example1.com/index.php
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, "http://example2.com/index.php");
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, 'your_data' => 'goes_here');
$result = curl_exec($ch);
curl_close($ch);
// on example2.com/index.php
$your_data = $_POST['your_data'];
答案 1 :(得分:-1)
是的,假设计算机能够连接,那么显而易见的方法是通过HTTP:
<?php
$message="Hello otherhost!";
$response=file_get_contents("http://otherhost.example.com/?data="
. urlencode($message));
print "I said \"$message\"<br />\nand other host replied \""
. htmlentities($response) . "\"";
?>
<?php
if (isset($_GET['data'])) {
print "Hello - you just said \"" . htmlentities($_GET["data"]) . "\"";
} else {
print "Sorry - I can't hear you";
}
?>