php读取MySQL数据并返回json数据

id = $row["id"];
		$user->name = $row["name"];
		$user->age = $row["age"];
		$user->sex = $row["sex"];
		$data[]=$user;
	}
	//打印编码后的json字符串
    $json = json_encode($data);
    echo decodeUnicode($json);
}else{
	echo "查询失败";
}
mysqli_close($con);
?>

 

你可能感兴趣的:(php)