Base Directory:
/home/ecedu/public_html/new/api
View File: header.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
header("Access-Control-Allow-Origin: https://sj.madarik.org");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type");
$userId = 1;
function respondText(string $message, int $statusCode = 200): void {
http_response_code($statusCode);
header('Content-Type: text/plain; charset=UTF-8');
echo $message;
exit;
}
function respondJson(array $data, int $statusCode = 200): void {
http_response_code($statusCode);
header('Content-Type: application/json; charset=UTF-8');
echo json_encode($data, JSON_UNESCAPED_UNICODE);
exit;
}