user3199791
user3199791

Reputation: 133

my IF statement not working as expected

I have written a simplified example of my problem below:

<?php
    if($spType=="SPI") {
    ?><div id="mainImageInside">

    <?php echo $sSeries ?>

    <?phpif($sSeries ==4) {
    ?><div id="buDepth" class="font">worked</div><?php}?>

    </div><?php
    ;
?>

$sSeries is set to 3 so when I echo it I get 3 printed out on my screen, the if statement expects a 4 therefore this should not print out the text "worked" however, it does print the text "worked" no matter if the value is set as 3 or 4, could someone please help me with this?

Upvotes: 1

Views: 126

Answers (1)

user557846
user557846

Reputation:

a million times more readable therfore easier to debug (for me at least)

<?php
if ($spType == "SPI") {

    echo '<div id="mainImageInside">' . $sSeries;

    if ($sSeries == 4 ) {
        echo '<div id="buDepth" class="font">worked</div>';
    }
    echo '</div>';
}
?>

Upvotes: 4

Related Questions