Complete the code to start a PHP script that outputs a simple message.
<?php
echo [1];
?>The echo statement requires a string in quotes to output text. So, "Hello, world!" is correct.
Complete the code to define a variable holding the current request method.
<?php $method = [1]['REQUEST_METHOD']; ?>
The $_SERVER superglobal contains server and execution environment information, including the request method.
Fix the error in the code that tries to start a session per request.
<?php
[1]();
// session code here
?>The correct PHP function to start a session is session_start(). Other options are invalid function names.
Fill both blanks to create an associative array with request method and URI.
<?php $request = [ 'method' => [1], 'uri' => [2] ]; ?>
$_SERVER holds both REQUEST_METHOD and REQUEST_URI. $_GET does not contain these server variables.
Fill all three blanks to create a response array with status, headers, and body.
<?php $response = [ 'status' => [1], 'headers' => [2], 'body' => [3] ]; ?>
The status code 200 means OK, headers is an associative array with content type, and body is a string with HTML content.