Can you see if my codes are working? My computer can't tell me the php results

php

#1


Sorry about all of this, but my computer hasn't been allowing me to see the outcome of my PHP codes because of my server. So I was wondering if y'all would check them and tell me which ones are correct and which ones are wrong? And if you know what's wrong? Thank you.


//Code 1

    <!DOCTYPE html>
    <html>
    <body>
    <h1>Fibonacci Series running PHP</h1>
    <?php
    $num_1 = 1;
    $num_2 = 1;
    $next_value = 1;
    echo "The first value is " .$num_1. "<br>";
    echo "The second value is " .$num_2. "<br>";
    for($i=0;$i<20;$i++){
    $next_value = $num_1 + $num_2;
    echo "<br>The next value is: " .$next_value;
    $num_1 = $num_2;
    $num_2 = $next_value;
    }
    ?>
    </body>
    </html>

//Code 2

    <!DOCTYPE html>
    <html>
    <body>
    <h1>Fibonacci While PHP</h1>
    <?php
    $i = 1;
    $num_1 = 1;
    $num_2 = 1;
    $next_value = 0;
    echo "The first value is " .$num_1. "<br>";
    echo "The second value is " .$num_2. " ";
    do { 
    $next_value = $num_1+$num_2;
    echo "<br>The next value is: " .$next_value;
    $num_1 = $num_2;
    $num_2 = $next_value;
    $i++;
    } while ($i <= 10);  
    ?>
    </body>
    </html>

//Code 3

    <!DOCTYPE html>
    <html>
    <body>
    <h1>Factorial For Loop PHP</h1>
    <?php
    $userInput = 11;
    $num_1 = 1;
    $num_2 = 1;
    $next_value = 1;
    echo "The first value is " .$num_1. "<br>";
    echo "The second value is " .$num_2. "<br>";
    $num_1 = $userInput;
    $num_2 = $num_1 - 1;
    for($i=0;$i<10;$i++){
    $next_value = $num_1 * $num_2;
    echo "<br>The next value is: " .$num_2;
    $num_2 = $num_2 - 1;
    $num_1 = $next_value;
    }
    ?>
    </body>
    </html>

//Code 4

    <!DOCTYPE html>
    <html>
    <body>
    <h1>Factorial PHP</h1>
    <?php
    $userInput = 10;
    $factorial = 1;
    $num_1 = 1;
    $num_2 = 1;
    echo "The first value is " .$num_1. "<br>";
    echo "The second value is " .$num_2. "<br>";
    do {	
    $factorial = $factorial * $userInput;
    echo "<br>The next value is: " .$userInput;
    $userInput--;
    } while ($userInput >= 1);  
    ?>
    </body>
    </html>

//Code 5

//Code 6

    <!DOCTYPE html>
    <html>    <!DOCTYPE html>
    <html>
    <body>
    <h1>Header Sizes For Loop PHP</h1>
    <?php
    for($i = 1; $i <= 4; $i++) { 
    echo "<h$i>header</h$i>"; 
    }
    for($i = 5; $i >= 1; $i--) { 
    echo "<h$i>header</h$i>"; 
    }
    ?>
    </body>
    </html>

    <body>
    <h1>Header Sizes While Loop PHP</h1>
    <?php 
    $x = 1;
    do {
    echo "The number is: $x <br>";
    $x++;
    } while ($x <= 5);
    ?>
    </body>
    </html>

//Code 7

<!DOCTYPE html>
<html>
<body>
<h1>Header Sizes While Loop PHP</h1>
<?php 
$x = 1;
do {
    echo "<h".$x.">Hello World"."</h".$x.">";
    $x++;
} while ($x <= 4; $x++);
$x = 5;
do {
    echo "<h".$x.">Hello World"."</h".$x.">";
    $x++;
} while ($x >= 5; $x--);
?>
</body>
</html>


#2

You can test your code at phpfiddle.org online


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.