php我有一个查询要在文件中查找用户的信息。我json_encode在同一个文件中使用将数据发送到,Ajax以便可以使用.html()函数显示它。
问题是,当我使用json_encode.
让我们假设我的 php 看起来像这样:-
foreach($pdo->query("SELECT * FROM Users WHERE ID='$id'") as $row) {
$firstname = $row['FirstName'];
$lastname = $row['LastName'];
}
$fullname = $firstname . " " . $lastname;
$data = array("success"=> true,"inpt"=>"<p>My name is $fullname</p>");
echo json_encode($data);
header("Content-Type: application/json");
我得到的是-> 我的名字是
如何使它工作?
我尝试使用$data = array("u_data"=> 'own',"inpt"=>"<p>My name is ".$fullname."</p>");但它没有工作..