0

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???

emiliorivas16
  • 119
  • 1
  • 7
  • The value is a valid JSON, though. If you load it directly as text, you won't get unescaped values. It should be used somewhere like a js script tag. Or you can copy it to the browser console and see it unescaped. – qrsngky Feb 24 '23 at 02:34
  • It appears that you might be able to pass `JSON_UNESCAPED_UNICODE` to the `options` parameter if you would like Unicode characters to not be escaped, however the original way might be the safer method, and is the PHP default way. Browsers are not really meant to be JSON viewers, there’s tools to do such things. – Chris Haas Feb 24 '23 at 04:06

0 Answers0