コード例 #1
0
ファイル: Admin.php プロジェクト: shapovalovei/Guest-book
 function response($data, $status = 200)
 {
     header("HTTP/1.1 " . $status . " " . _requestStatus($status));
     return json_encode($data);
 }
コード例 #2
0
ファイル: index.php プロジェクト: andreasunteidig/de-routing
function _sendData($data = array(), $status = 200, $onlyFirst = false)
{
    // headers for not caching the results
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    // allow all requests
    header("Access-Control-Allow-Orgin: http://farseer.de");
    header("Access-Control-Allow-Methods: *");
    // headers to tell that result is JSON
    header('Content-type: application/json');
    //send status
    header("HTTP/1.1 " . $status . " " . _requestStatus($status));
    // send the result now
    if ($onlyFirst && !empty($data)) {
        echo json_encode($data[0]);
    } else {
        echo json_encode($data);
    }
    //end script
    exit;
}