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.
Syntactically, the expression with the ternary operator, is a single instruction, and you cannot break a single instruction across PHP tags, regardless of nesting PHP and HTML code blocks.
For example, the followings generate syntax errors: