Created
December 27, 2018 22:12
-
-
Save mriso79/c1e0eca18c3e44d61e3f5986c443bac6 to your computer and use it in GitHub Desktop.
A decent JSON response with Charset UTF-8 with PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace lib\http; | |
class JsonResponse { | |
function __construct(){} | |
public static function simpleJsonResponse($object){ | |
header('Content-Type: application/json; charset=utf-8'); | |
echo json_encode($object, JSON_FORCE_OBJECT); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The namespace refers to one of my projects so you can remove or customize according to your own project.