Monday, 15 April 2013

php - If and Else If Progress Bar -



php - If and Else If Progress Bar -

below simple progress bar module i'm trying create.

<?php $progress = 3; if($progress = 2) { echo "<pre>progress 2"; var_dump($progress); echo "</pre><br>"; $progressprint = " <div class='one progressbar'></div> <div class='two progressbar'></div> ";echo $progressprint; } elseif($progress = 3) { echo "<pre>progress3"; var_dump($progress); echo "</pre><br>"; $progressprint = " <div class='one progressbar'></div> <div class='two progressbar'></div> <div class='three progressbar'></div> ";echo $progressprint; } elseif($progress = 4) { $progressprint = " <div class='one progressbar progressbar'></div> <div class='two progressbar'></div> <div class='three progressbar'></div> <div class='four progressbar'></div> ";echo $progressprint; } else { echo "nothing"; } ?>

the way set testing manual input of $progress variable. there i'm testing against integer. reason can't read $progressbar == 3 elseif.

the var dump shows we're sticking in 2 when variable 3.

as per op's wish close question , marked solved:

you're assigning if($progress = instead of comparing if($progress ==

assignment: http://php.net/manual/en/language.operators.assignment.php

comparison: http://php.net/manual/en/language.operators.comparison.php

php int var-dump

No comments:

Post a Comment