Arithmetic Operations

Problem 1

Write a program to print “Hello World” using echo

Description: Write a program to print “Hello World” using echo only?

Conditions: You can not use any variable.

Solution:

echo "Hello World";

Output:

Hello World

Problem 2

Write a program to print “Hello PHP” using variable

Description:Write a program to print “Hello PHP” using php variable?

Conditions: You can not use text directly in echo but can use variable.

Solution:

$a = "Hello PHP";
echo "$a";

Output:

Hello PHP

Problem 3

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

Description:Write a program to print “Welcome to the PHP World” using some part of the text in variable & some part directly in echo.

Conditions: You have to use a variable that contains string “PHP World”.

Solution:

$b = "PHP World";
echo "Welcome to the " . "$b";

Output:

Welcome to the PHP World

© 2024 Ceejay Nilles. All rights reserved.