$_POST['author'], 'text' => $_POST['text']]; $comments = json_encode($commentsDecoded, JSON_PRETTY_PRINT); file_put_contents('comments.json', $comments); } header('Content-Type: application/json'); header('Cache-Control: no-cache'); echo $comments; } else { return false; } }