error text encode php json

PHP
<?php
...
$json_string = json_encode($data, JSON_PRETTY_PRINT);
Source

Also in PHP: