Helpers::sendJson PHP Method

sendJson() public static method

public static sendJson ( array $data )
$data array
    public static function sendJson(array $data)
    {
        header('Content-Type: application/json');
        echo json_encode($data);
        exit;
    }

Usage Example

Beispiel #1
0
function checkAdminAuth()
{
    if (!checkAuth()) {
        return false;
    }
    global $session, $app;
    if ('admin' !== $session->getUserType()) {
        Helpers::sendJson(array('error' => array('error_code' => 'forbidden', 'error_msg' => 'Доступ мають лише адміністратори')));
        return false;
    }
    return true;
}
All Usage Examples Of Helpers::sendJson