PHP Programs

Comments · 135 Views

Here there are most important PHP programs that are frequently asked in the interview. These programs are from PHP basics, PHP control statements, PHP array, PHP string, PHP oops, PHP file handling etc.

php programs


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. ?php  
  2. $number=1233456;  
  3. if($number%2==0)  
  4. {  
  5.  echo "$number is Even Number";   
  6. }  
  7. else  
  8. {  
  9.  echo "$number is Odd Number";  
  10. }   
  11. ?  


PHP Even odd program 1

Alphabet Triangle using PHP method

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

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


PHP Alphabet triangle pattern 1

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. ?php  
  2. for($i=0;$i=5;$i++){  
  3. for($j=5-$i;$j=1;$j--){  
  4. echo "* ";  
  5. }  
  6. echo "br";  
  7. }  
  8. ?  


PHP Star triangle 1