samedi 20 juin 2015

How to enclose HTML in a ternary operator condition as you would with a normal if statement

When i'm using the IF Statement, I normally do something like this;

    <?php 
    if ($var ===0){ ?>
    <section>We broke out of PHP</section>
    <?php ////// we are back in PHP 
    } else {

        }       
 ?>

How can I archive the same thing with a ternary operator, something like

  <?php 
    $var ===0?: $_breakHere?>
    <section>We broke out of PHP</section>
    <?php ////// we are back in PHP 
    $_ContinueHere
    } else {

        }       
 ?>

I'd put all the html block into a PHP variable, but I want to break our of PHP and back into it, for syntax reading purposes.

Aucun commentaire:

Enregistrer un commentaire