Skip to content

Instantly share code, notes, and snippets.

@alexlatam
Created May 30, 2024 13:19
Show Gist options
  • Save alexlatam/1a322f5606f4ae35a5406e02dfe8ae0f to your computer and use it in GitHub Desktop.
Save alexlatam/1a322f5606f4ae35a5406e02dfe8ae0f to your computer and use it in GitHub Desktop.
Simple Api on Pure PHP - Without frameworks
<?php
init_set('display_errors', 0);
init_set('html_errors', 0);
$message = new stdClass();
$message->content[0] = "Hi there!";
$message->content[1] = "See you later";
/** Headers Response **/
header('Content-Type: application/json; charset=utf-80); // response tpye
header('HTTP:1.1 200 OK'); // status code
echo json_encode($message);
exit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment