PHP Exercises, Practice, Solution | PHP programming exercises

To learn any programming language you have to practice the programs, this is one of the best and faster way to learn programming language.

PHP is a open source general-purpose scripting language that is especially suited for web development & can be embedded into HTML.

What is PHP used for?

  • Static Websites
  • Web applications
  • Desktop (GUI) applications
  • Command line scripting

List of PHP Programs →

List of PHP basic programs with examples

  1. Write a PHP script to display ‘Hello World!’
  2. Create a HTML form that accept the user name and display the name using php
  3. Write a PHP script to get the client IP address
  4. Write a simple PHP browser detection script
  5. Write a PHP script, which changes the color of the first character of a word
  6. Write a PHP script to redirect a user to a different page
  7. Write a simple PHP program to check that email id is valid or not
  8. Write a PHP script to display string, values within a table
  9. Write a PHP function to test whether a number is greater than 30, 20 or 10 using ternary operator
  10. Write a PHP program to swap two variables
  11. Write a PHP program to check if a number is an Armstrong number or not
  12. Write a PHP program to convert word to digit
  13. Write a PHP program to remove duplicates from a sorted list
  14. Write a PHP program to compute the sum of the prime numbers less than 200
  15. Write a PHP program to print out the multiplication table upto 5*5
  16. Write a PHP program to compute the sum of the digits of a number
  17. Write a PHP program that multiplies corresponding elements of two given lists

List of PHP array programs with examples

  1. Write a PHP script which will display the Cars in the following way using array
  2. Write a PHP script to get the Second element of the above array
  3. Write a PHP script that inserts a new item in an array in any position
  4. Write a PHP script to calculate and display average temperature, five lowest and highest temperatures
  5. Write a PHP script which displays all the numbers between 50 and 150 that are divisible by 4
  6. Write a PHP script to get the shortest/longest string length from an array
  7. Write a PHP script to generate unique random numbers within a range
  8. Write a PHP function that returns the lowest integer that is not 0
  9. Write a PHP script to sort an array in reverse order (highest to lowest)
  10. Write a PHP function to set union of two arrays

List of Loop programs with examples

  1. Write a PHP script that displays 1 2 3 4 5 6 7 8 9 10 numbers on one line
  2. Write a PHP script using a for loop to add all the integers between 0 and 20 and display the sum
  3. Write a PHP script to calculate and print the factorial of a number using a for loop
  4. Write a program which will count the “t” characters in the text “techstudy”
  5. Write a PHP script using nested for loop that creates a chess board
  6. Write a PHP script to print all even numbers between 1 to 10
  7. Write a PHP script to print all odd numbers between 1 to 10
  8. Write a PHP Script to sum of even numbers from 1 to 10
  9. Write a PHP Script to sum of odd numbers from 1 to 10
  10. Write a PHP program to print table of number

List of String programs with examples

  1. Write a PHP script to convert lowercase string to uppercase
  2. Write a PHP script to convert uppercase string to lowercase
  3. Write a PHP script to convert first character uppercase
  4. Write a PHP script to convert first character of all the words uppercase
  5. Write a PHP script split the following string
  6. Write a PHP script to extract the user name from the email ID
  7. Write a PHP script to get the last three characters of a string
  8. Write a PHP script to replace the first ‘the’ of the following string with ‘best’
  9. Write a PHP script to generate simple random password from a given string
  10. Write a PHP script to print the next character of a specific character
  11. Write a PHP script to remove a part of a string from the beginning
  12. Write a PHP script to insert a string at the specified position in a given string
  13. Write a PHP script to remove all leading zeroes from a string
  14. Write a PHP script to remove comma(s) from the following numeric string
  15. Write a PHP script to get the first word of a sentence
  16. Write a PHP script to print letters from ‘a’ to ‘z’
  17. Write a PHP script to select first 6 words from the following string

All star pattern programs in PHP


All Alphabet programs in PHP

1 thought on “PHP Exercises, Practice, Solution | PHP programming exercises”

Leave a Comment