[PHP]JSON形式で返却する
json形式返却時のutil関数。
<?php /** 正常返却 **/ function ok($responseArray) { $ret['success'] = true; $ret['data'] = $responseArray; header('Content-Type: application/json'); if(function_exists("json_encode")) { echo json_encode($ret); } else { //PHPバージョンが5.2.0未満の場合で json_encode() 関数がない場合 require_once 'JSON.php'; $json = new Services_JSON(); echo $json->encode($ret); } } ?>