Files
fast_install/api/helpers.php
T

26 lines
647 B
PHP

<?php
function json_response($data, $code = 0, $message = 'success') {
header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
echo json_encode([
'code' => $code,
'message' => $message,
'data' => $data
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
exit;
}
function json_error($message, $code = 5000) {
json_response(null, $code, $message);
}
function get_request_path() {
$uri = $_SERVER['REQUEST_URI'] ?? '/';
$pos = strpos($uri, '?');
if ($pos !== false) {
$uri = substr($uri, 0, $pos);
}
return rtrim($uri, '/');
}