Behseini Behseini - 22 days ago 6
PHP Question

Having Issue On PHP Increment

Can you please take a look at this demo and let me know why I am not able to increment the

$start
as the output is looks like
88888
only

<?php
for($i = 1; $i<= 5; $i++){
$start = 8;
echo $start;
$start++;
}
?>

Answer

That is because you always assign your value inside loop , take it out

<?php

    $start = 8;
    for($i = 1; $i<= 5; $i++){

        echo $start;
        $start++;
        }
?>