Complete the code to print "Hello, World!" in PHP.
<?php
echo [1];
?>In PHP, strings must be enclosed in quotes. Using double quotes "Hello, World!" prints the exact text.
Complete the code to declare a variable named $name with the value "Alice".
<?php [1] = "Alice"; ?>
In PHP, variables start with a dollar sign $. So $name is the correct variable name.
Fix the error in the PHP code to correctly concatenate two strings.
<?php $greeting = "Hello" [1] " World!"; echo $greeting; ?>
In PHP, the dot (.) operator is used to join strings together.
Fill both blanks to create an associative array with keys "name" and "age".
<?php $person = array([1] => "Bob", [2] => 30); ?>
Array keys must be strings in quotes. So use "name" and "age" as keys.
Fill all three blanks to write a PHP function named greet that takes a $name and returns a greeting string.
<?php function [1]([2]) { return "Hello, " . [3] . "!"; } ?>
The function name is greet. The parameter and variable used inside must be $name with the $ sign.