PHP Programs

Posted by sanjeev kumar on November 29th, 2021

Here, at phptpoint we begin from the scratch where we can lead you on the practice of these languages.

This is a free and online site where the students who want to build a career in the same profession, can be trained about the working of the PHP. 

The following are the most important PHP programs that are frequently asked in interviews. These programs cover PHP fundamentals, PHP control statements, PHP arrays, PHP strings, PHP oops, PHP file handling, and so on.

Even Odd Program

A program to check 1233456 is odd or even is shown.


  1. $number=1233456;  
  2. if($number%2==0)  
  3. {  
  4.  echo \"$number is Even Number\";   
  5. }  
  6. else  
  7. {  
  8.  echo \"$number is Odd Number\";  
  9. }   
  10. ?>  



Alphabet Triangle using PHP method

Some different alphabet triangle patterns using range() function in PHP are shown below.

  1. $alpha = range(\'A\'\'Z\');  
  2. for($i=0; $i<5; $i++){   
  3.   for($j=5; $j>$i$j--){  
  4.     echo $alpha[$i];  
  5.     }  
  6.     echo \"
  7. }  
  8. ?>  



Star Triangle

The star triangle in PHP is made using for and foreach loop. There are a lot of star patterns. We\'ll show some of them here.

Pattern 1

  1. for($i=0;$i<=5;$i++){  
  2. for($j=5-$i;$j>=1;$j--){  
  3. echo \"* \";  
  4. }  
  5. echo \"
  6. }  
  7. ?>  



Like it? Share it!

sanjeev kumar

About the Author

sanjeev kumar
Joined: March 24th, 2021
Articles Posted: 34

More by this author