Created
August 23, 2017 15:09
-
-
Save yoheiMune/9a68c617feb239782c4def8cee2eba3f to your computer and use it in GitHub Desktop.
JSONを返却するサンプルです
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// レスポンスヘッダーをJSONに指定する | |
header('Content-Type: application/json'); | |
// 例えば、以下のデータを返したい場合に | |
$user = array( | |
'id' => 1, | |
'name' => 'Yohei' | |
); | |
// このようにJSONで返却できます | |
print(json_encode($user)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment