I have the following code, which works exactly as I expect it to:
<?php if ($a - $b < 1)
echo $text;
elseif ($a - $b >= 1)
echo $a - $b;
else
echo $a; ?>
However, now I also want to add a bit of HTML to the echo depending on the result of the IF statement.
<?php if ($a - $b < 1)
echo $text;
elseif ($a - $b >= 1)
echo $a - $b;
<input type="button" value="<?php echo $button_txt; ?>" id="button" class="button" />
else
echo $a;
<input type="button" value="<?php echo $button2_txt; ?>" id="button" class="button" /> ?>
When I do this, I get the following error: Parse error: syntax error, unexpected '<' on line 213 (line 213 is referring to the first <input>
line in the code above).
Is there any way to include both the variables, and the HTML in the echo part of the IF statement?
<input>
tags supposed to be part of the if/else chain? if so you'll also need{}
or you'll get a syntax error at theelse
. – Michael Berkowski May 16 '12 at 18:11