Activity 2

Problem 1.
Write a program to print “Hello World” using echo

Solution:

//Echo the statement "Hello World"
echo "Hello World!";

Output:

Hello World!


Problem 2.

Write a program to print “Hello PHP” using variable

Solution:

//Declare a variable that will hold the string "Hello PHP"
$x = "Hello PHP";

//Echo the variable
echo $x

Output:

Hello PHP


Problem 3.

Write a program to print a string using echo + variable.

Solution:

//Declare a variable to hold the value
$y = "PHP World";

//Concatinate the string "Welcome to the" and the declared variable
echo "Welcome to the ". $y. "!";

Output:

Welcome to the PHP World!