How Can I Echo Html in Php?
I Want to Conditionally Output Html to Generate a Page, So What's the Easiest Way to Echo Multiline Snippets of Html in Php 4+? Would I Need to Use a Template...
I want to conditionally output HTML to generate a page, so what's the easiest way to echo multiline snippets of HTML in PHP 4+? Would I need to use a template framework like Smarty?
echo '<html>', "\n"; // I'm sure there's a better way!
echo '<head>', "\n";
echo '</head>', "\n";
echo '<body>', "\n";
echo '</body>', "\n";
echo '</html>', "\n";
13 Answers
There are a few ways to echo HTML in PHP.
Must Read
1. In between PHP tags
<?php if(condition){ ?>
<!-- HTML here -->
<?php } ?>