7+ PHP Programs to Print Fibonacci Series

This post contains a total of 7+ PHP Program Examples with Source Code to Print Fibonacci Series. All these Fibonacci Series programs are made using PHP.

You can use the source code of these examples with credits to the original owner.

Related Posts

PHP Programs to Print Fibonacci Series

1. By Ziyua

Made by Ziyua. Simple PHP Program that prints Fibonacci series numbers from 0 to 100. Source

1
1
2
3
5
8
13
21
34
55
89
<?php
    $i=1; $k=1; $g=0;
    while($i<=100){
        echo "<p>$i</p>";
        $g=$i; $i=$k; $k+=$g;
    }
?>

2. By Sam

Made by Sam. Fibonacci series program for the first 12 numbers. Source

Fibonacci series for the first 12 numbers
1
2
3
5
8
13
21
34
55
89
<?php
$num = 0;
$n1 = 0;
$n2 = 1;
$sum = 0;
echo "<h3>Fibonacci series for the first 12 numbers</h3>";
while($num < 10){
$sum = $n1 + $n2;
echo $sum." <br>";
$n1 = $n2;
$n2 = $sum;
$num = $num + 1;
}
?>

3. By Panda

Made by Panda. Basic Fibonacci Series program, prints 5 numbers. Source

0 11
2
3
5
8
<?php
    $num=0;$n1=0;$n2=1;
    echo $n1.' '.$n2;
    for($i=0;$i<5;$i++)
    {
        $n3=$n1+$n2;
        echo $n3;
        echo "<br>";
        $n1=$n2;
        $n2=$n3;
    }
?>

4. By Toyin Samad Akanbi

Made by Toyin Samad Akanbi. Fibonacci series Program using recursive function. Source

0 1 1 2 3 5 8 13 21 34
<?php  

$num = 10;  
echo "\n";  
  
function series($num){  
    if($num == 0){  
    return 0;  
    }else if( $num == 1){  
return 1;  
}  else {  
return (series($num-1) + series($num-2));  
}   
}  
/* Call Function. */  
for ($i = 0; $i < $num; $i++){  
echo series($i);  
echo "\n";  
}  

5. By Parth Joshi

Made by Parth Joshi. Source

00112358132134
<?php
    $a=0;
    $b=1;
    $c=0;
    $no=10;
    echo $c;
   for($i=1;$i<=$no;$i++) 
    {  
        echo $c;
        $a=$b;
        $b=$c;
        $c=$a+$b;
        
    }
    
?>

6. By Dicky Rinaldy

Made by Dicky Rinaldy. Source

0 1 1 2 3 5 8 13 21 34 55 89
<?php
    $angka1 = 0;
    $angka2 = 1;
    
   echo $angka1."\t";
   echo $angka2."\t";
    
    for ($i=1; $i<=10; $i++){
       $output = $angka1 + $angka2 ;
       $angka1 = $angka2 ;
       $angka2 = $output;
       
       echo $output."\t";
    }
?>

7. By Aniket Yadav

Made by Aniket Yadav. Source

fibonacci series
0
1
1
2
3
5
8
13
21
34
55
89
144
<?php
    echo "fibonacci series<br>";
    $a=0;
    $b=1;
    echo $a."<br>".$b."<br>";
    for($i=0;$i<=10;$i++)
    {
        $c=$a+$b;
        echo $c."<br>";
        $a=$b;
        $b=$c;
        }    
?>

8. By dbansalin

Made by dbansalin. PHP Program to Print Fibonacci Series from 0 to 100. Source

1
1
2
3
5
8
13
21
34
55
89
<?php
    
    $c = 1;
    $r = 0;
    $t = 0;
    
    for ($i = 0; $i <= 10; $i++)
    {
        $t = $c + $r;
        $c = $r;
        $r = $t;
        
        echo $r . '<br/>';
    }

?>