Can't convert JSON from UNICODE to UTF-8 using flightphp

86 Views Asked by At

This is my first time using flightphp so be nice with me, I have tried everything and still not working so here we go...

I have this basic code in PHP using the micro-framework flightphp to create an API, in this specific case is just the method GET:

<?php

require 'flight/Flight.php';

Flight::register('db', 'PDO', array('mysql:host=localhost;dbname=api','root',''));


Flight::route('GET /personas', function () {

    $sentence = Flight::db()->prepare("SELECT * FROM `persons`");
    $sentence->execute();
    $data = $sentence->fetchAll(PDO::FETCH_ASSOC);

    Flight::json($data);

});


Flight::start();

?>

In the browser is showing me this:

enter image description here

WHen I use my Rest API Client simulator (postman, insomnia, etc) It shows it correctly

enter image description here

How can I fix it to show it correctly in the browser???

0

There are 0 best solutions below