Write a program to count 5 to 15 using PHP loop

Description:
Write a Program to display count, from 5 to 15 using PHP loop as given below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Rules & Hint

  • You can use “for” or “while” loop
  • You can use variable to initialize count
  • You can use html tag for line break

Click below to View Solution/Program


Output:
5
6
7
8
9
10
11
12
13
14
15


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.

Click to View Solution/Program

Output:Hello World


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.

Click to View Solution/Program

Output: Hello PHP


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”.

Click to View Solution/Program

Output:

  Welcome to the PHP World

Write a program to print two variables in single echo

Description:
Write a program to print 2 php variables using single echo statement.

Conditions:

  • First variable have text “Good Morning.”
  • Second variable have text “Have a nice day!”
  • Your output should be “Good morning. Have a nice day!”
  • You are allowed to use only one echo statement in this program.

Click to View Solution/Program

Output:

  Good Morning. Have a nice day!

Write a program to check student grade based on marks

Description:

Write a program to check student grade based on the marks using if-else statement.

Conditions:

  • If marks are 60% or more, grade will be First Division.
  • If marks between 45% to 59%, grade will be Second Division.
  • If marks between 33% to 44%, grade will be Third Division.
  • If marks are less than 33%, student will be Fail.

Click to View Solution/Program

Output:

  Student grade: Third Division

Write a program to show day of the week using switch

Description:

Write a program to show day of the week (for example: Monday) based on numbers using switch/case statements.

Conditions:

  • You can pass 1 to 7 number in switch
  • Day 1 will be considered as Monday
  • If number is not between 1 to 7, show invalid number in default

Click to View Solution/Program

Output:

  It is Friday!

Write a factorial program using for loop in php

Description:

Write a program to calculate factorial of a number using for loop in php.

Output:

  The factorial of 3 is 6

Factorial program in PHP using recursive function

Exercise Description:
Write a PHP program to find factorial of a number using recursive function.

What is Recursive Function?

  • A recursive function is a function that calls itself.

Factorial program in PHP using recursive function

Output:

  24

Write a program to create Chess board in PHP using for loop

Description:

Write a PHP program using nested for loop that creates a chess board.

Conditions:

  • You can use html table having width=”400px” and take “30px” as cell height and width for check boxes.

Click to View Solution/Program

Output:
Chess-board-in-PHP-using-for-loop