vendredi 21 avril 2017

PHP "if / Else" with html in the middle

I am having trouble getting some code to work. I am trying to do a "if variable exists show this page if not do this" with a php/html based page.

<?php
if ($a == 2)
{
?>
HTML STUFF
<?php SOME PHP STUFF ?>
SOME MORE HTML STUFF
<?php }
else
{
OTHER STUFF
}
?>

When this is done it simply goes straight to the "else" regardless of if "a=2" or not i think the issue is caused by leaving PHP half way through the command.

There is a LOT of html lines so i don't really want to go echo""; for every line. I hope i'm wrong but, is that the cause of my problem? and if so is there another way of getting it working?

Aucun commentaire:

Enregistrer un commentaire