PHP Code to print first 10 Fibonacci Numbers

PHP Code:

<!DOCTYPE html>
<html>
<body>
<h3>Php Code to print first 10 Fibonacci Numbers</h2>

<?php
    $number = 10;
    $i = 2;
    $res = 1;
    $last = 0;
    echo "<h3>Fibonacci series....</h3>";
    echo "<h3>0 1 ";
    while($i <= $number){
        $temp = $res + $last;
        echo $temp, " ";
        $last = $res;
        $res = $temp;
        $i = $i + 1;
    }
    echo "</h3>"
?> 

</body>
</html>

Output:

Comments

Popular posts from this blog

Create a simple HTML page to demonstrate the use of different tags

Use Tables to provide layout to your web page.