PHP if/else without echo -
how replace echo
proper html codes? since there hundreds of html codes, using echo doesn't make sense.
<?php if ($this->item->catid == 9) { echo "yes, exists"; } else { echo "no, don't exist"; } ?>
i'm new php.
do mean, how can 1 cleanly output many lines of html conditionally without having echo
each individual line?
if that's case, trick:
<?php if ($this->item->catid == 9) { ?> <!--- put raw output here ---> <?php } else { ?> <!--- put raw output here ---> <?php } ?>
the "raw output" sent browser. html, javascript, etc. though it's outside of server-side php tags, far php processor concerned it's still between { ... }
brackets. it's output part of conditional block.
Comments
Post a Comment