При GET запросе все JSON все русские буквы превратились в знаки вопросов.
PHP - cкрипт:
<?php
class Sql{
public $password = '****';
public $user = '****';
public $database = '****';
public $host = 'localhost';
var $querydb;
public $response;
function Connect_db($query, $dowhile = false){
/*ini_set('display_errors', 1); ini_set('error_reporting', E_ALL);*/
// подключаемся к серверу
$link = mysqli_connect($this->host, $this->user, $this->password, $this-
>database)
or die(trim("Error") . mysqli_error($link));
$this->querydb = $query;
$result = mysqli_query($link, $this->querydb) or die();
if($result)
{
unset($this->response);
if($dowhile == true){
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
//return $row;
$this->response[] = $row;
}
}
else{
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$this->response = $row;
}
return $this->response;
}
// закрываем подключение
mysqli_free_result($row);
mysqli_close($link);
}
}
$sql = new Sql;
$duck = $sql->Connect_db("SELECT * FROM base_data LIMIT 0, 99",true);
$data = array("company"=>"HeaSoft", "copyright"=>"© 2017, HeaSoft",
"news"=>$duck);
echo json_encode($data);
?>
JSON выдается вот такой: {"company":"HeaSoft","copyright":"\u00a9 2017, HeaSoft","news":[{"id":"1","name":"?????? ???????????? ??????????","title":"?????? ???????????? ??????????","author":"????? ?.?.","created_at":null,"content":"HeaSoft ????????? ???? ??????????? ????????? ??????! ??????????? ???? ? ????!","bigcontent":"simple","type":null,"urlToImage":null,"likes":"0"},{"id":"2","name":"?????????? ? GooglePlay","title":"?????????? ? GooglePlay","author":"????? ?.?","created_at":"today","content":"???-??? ???? ?????? ????????? ?????????? ????? ???????????? ? GooglePlay ?? ???????? ?????????. ???? ???????????","bigcontent":"???-??? ???? ?????? ????????? ?????????? ????? ???????????? ? GooglePlay ?? ???????? ?????????. ???? ???????????","type":"simple","urlToImage":"googleplay","likes":"0"},{"id":"3","name":"????? ??????. ????????.","title":"????? ??????. ????????.","author":"????? ?.?","created_at":"today","content":"????? ?????????? ????? ??? ?????? ??????????! ?????? ??? ?????? ?????? ????? ??????? ????????!","bigcontent":"????? ?????????? ????? ??? ?????? ??????????! ?????? ??? ?????? ?????? ????? ??????? ????????!","type":"simple","urlToImage":"pictures","likes":"0"},{"id":"4","name":"?????????? ?? ???? ???? ?????????.","title":"\u0000?????????? ?? ???? ???? ?????????.","author":"????? ?.?","created_at":"today","content":"?????????? ?????? ??????? ?????????? ?????????? ????????? ?????????. ????? ?? ??????? ??????????? ???????? ?? ??????? ????? ?? ??????????.","bigcontent":"?????????? ?????? ??????? ?????????? ?????????? ????????? ?????????. ????? ?? ??????? ??????????? ???????? ?? ??????? ????? ?? ??????????.","type":"simple","urlToImage":"googlepub","likes":"0"},{"id":"5","name":"?????? ????? ??????????! ?? ??????? ?????.","title":"\u0000?????? ????? ??????????! ?? ??????? ?????.","author":"????? ?.?","created_at":"today","content":"????? ?????????? ????? ???-??? ??????, ??? ???????????? ?????? ??????? ?????. ????? ?? ??????? ????? ????? ?????????? ????????, ?? ??? ?? ?????.","bigcontent":"????? ?????????? ????? ???-??? ??????, ??? ???????????? ?????? ??????? ?????. ????? ?? ??????? ????? ????? ?????????? ????????, ?? ??? ?? ?????.","type":"simple","urlToImage":"like","likes":"0"}]}
И вот база данных:База данных
var_dump($data);
что выведет вместоecho json_encode($data);
? И какая кодировка страницы при этом будет в браузере?$this->querydb = $query;
добавьтеmysqli_set_charset($link, 'utf8');