HttpUrlConnect.getInputStream() confusion


HttpUrlConnect.getInputStream() confusion

在我的应用程序中,我建立了这个http连接。

String first = params[1];
String last = params[2];
String email = params[3];
String password = params[4];
URL url = new URL(register_url);
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String post_data = URLEncoder.encode("first","UTF-8")+"="+URLEncoder.encode(first,"UTF-8")+"&"
        +URLEncoder.encode("last","UTF-8")+"="+URLEncoder.encode(last,"UTF-8")+"&"+URLEncoder.encode("email","UTF-8")+"="+URLEncoder.encode(email,"UTF-8")
        +"&"+URLEncoder.encode("password","UTF-8")+"="+URLEncoder.encode(password,"UTF-8");
bufferedWriter.write(post_data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
String result="";
String line="";
while((line = bufferedReader.readLine())!= null) {
    result += line;
}

上面的代码连接到远程服务器中的php文件

<?php 
require "conn.php";
$email = $_POST["email"];
$password = $_POST["password"];
$mysql_qry = "select * from arsenal_data where email like '$email' and      password like '$password';";
$result = mysqli_query($conn ,$mysql_qry);
if(mysqli_num_rows($result) > 0) {
echo " Remote login success!";
}
else {
echo " Remote login fails!";
}
?>

我的问题是,为什么 htttpURLConnect.getInputStream() 的结果是 php 文件中的 echo 语句中的"远程登录成功!"?我假设php文件中的"echo"语句只是显示一条消息?这个和 php 文件中的 $_GET["字符串"]有什么区别?这两种方法都是从服务器中的 php 文件向客户端发送消息?

在 PHP

中,$_GET 变量保存来自发送到 PHP 服务器的 HTTP 请求的查询参数。 所以它是一个"输入"。 echo用于在 HTTP 响应正文中发送回文本,因此它是一个"输出"。