28 lines
560 B
PHP
28 lines
560 B
PHP
<?php
|
|
|
|
namespace lib\Core;
|
|
|
|
class Response
|
|
{
|
|
public static function json($data, int $status = 200)
|
|
{
|
|
http_response_code($status);
|
|
header('Content-Type: application/json');
|
|
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
public static function view(string $html, int $status = 200)
|
|
{
|
|
http_response_code(200);
|
|
header('Content-Type: text/html');
|
|
echo $html;
|
|
}
|
|
|
|
public static function text(string $text, int $status = 200)
|
|
{
|
|
http_response_code($status);
|
|
header('Content-Type: text/plain');
|
|
echo $text;
|
|
}
|
|
}
|