PHP Exercises

Fill in the blanks to complete the code.

1

Declare a PHP variable called username

= "Alice";
2

Output text to the browser

"Hello, World!";
3

Create an indexed array

$colors = ("red", "green", "blue");
4

Define a function called greet

greet($name) { return "Hello, $name"; }
5

Get the length of a string

$len = ("Hello");
6

Convert a string to uppercase

$upper = ("hello");
7

Check if a variable is set

if (($name)) { echo $name; }
8

Open PHP tags to start a PHP block

php echo "Hello"; >