此php文件返回Jason编码的响应。但是我的问题是,除了Jason编码解码器响应之外,它还在响应的前面加上了“ <”。Here its a picture with the response.
如何删除它?
<?php
require 'connection.php';
if (isset($_POST['username']) && !empty($_POST['username']) && isset($_POST['password']) && !empty($_POST['password'])) {
$username = $_POST["username"];
$password = $_POST["password"];
$statement = mysqli_prepare($idCon, "SELECT * FROM user WHERE username = ? AND password = ?");
mysqli_stmt_bind_param($statement, "ss", $username, $password);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $user_ID, $name, $username, $password);
$response = array();
$response["success"] = false;
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["name"] = $name;
$response["username"] = $username;
$response["password"] = $password;
}
echo json_encode($response);
}
else{
$response = array();
$response["success"] = false;
echo json_encode($response);
}
?>
连接php文件(我将$ nameUser,$ pass,$ bazaDeDate中的日期替换为“ ***”):
<?php
$nameServer="localhost";
$nameUser="******";
$pass="*****";
$bazaDeDate="****";
$idCon=mysqli_connect($nameServer,$nameUser,$pass);
if(!$idCon)
die ('Con failed');
$rezultatSelectBD=mysqli_select_db($idCon,$bazaDeDate);
if(!$rezultatSelectBD)
die ('Con failed');
?>
答案 0 :(得分:0)
在原始脚本中检查您的php开头标签。如果找不到错误,则将代码的各个部分一一忽略,直到找到将这个“ <”符号留下的代码为止