index.php - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of index.php.php

  1. <?php
  2. $contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
  3.  
  4. if ($contentType === "application/json") {
  5.   //Receive the RAW post data.
  6.   $content = trim(file_get_contents("php://input"));
  7.  
  8.   $decoded = json_decode($content, true);
  9.  
  10.   //If json_decode failed, the JSON is invalid.
  11.   if(! is_array($decoded)) {
  12.  
  13.   } else {
  14.     // Send error back to user.
  15.   }
  16. }
  17. ?>
  18.  
File Description
  • index.php
  • PHP Code
  • 27 Jan-2020
  • 394 Bytes
You can Share it: