PHP Exercises

Tutorials Class provides you exercises on various PHP Topics such as PHP basics, variables, operators, loops, forms, and database. This page is an Index for PHP Exercises.

Choose the PHP Exercise type that you want to practice. Practice your PHP skills using PHP Exercises & Assignments.

Here, you will find a list of PHP programs, along with problem description and solution. These programs can also be used as assignments for PHP students.

Write a PHP program to reverse the string

Description:
Write a PHP program to reverse the string.

Instructions:

  • You can use any string related built-in Function.
  • You can use only one variable.

Click to View Solution/Program:


Write a PHP program to find the length of the string

Description:
Write a PHP program to find the length of the string.

Instructions:

  • You have to use one variable.
  • You must use a built-in PHP String Function.

Click to View Solution/Program:


Write a PHP program to count the words in the string

Description:
Write a PHP program to count the words in the string.

Instructions:

  • You can use only one variable.
  • You can use PHP built-in String Function.
Click to View Solution/Program


Write a PHP program to convert a string into uppercase

Description:
Write a PHP program to convert all the characters inside the string into uppercase.

Instructions:

  • You can use only one variable.
  • You should use a PHP built-in string Function
Click to View Solution/Program


PHP Array to String Conversion (favorite colors chosen by user)

Description:
Write an exercise for PHP Array to String Conversion.

  • Create a form that accept name as well as colors
  • After submission, form data will be sent to another page
  • Display select colors (as a list) and user name
  • User name & colors selection is mandatory

Click below to View Solution/Program


Amit’s favorite colors are 3 option(s):

red

green

blue