If you do not want to use the template engine, you can use the capabilities of the basic PHP template.
Actually, you should just write HTML, and whenever you need to output the value of a variable, open the PHP part with <?php and close it with ?> . I will assume for examples that $data is your data object.
For example:
<div id="fos"><?php echo $data->getWhatever(); ?></div>
Note that all PHP management structures (e.g. if , foreach , while , etc.) also have syntax that can be used for templates. You can see them on your PHP manual pages.
For example:
<div id="fos2"> <?php if ($data->getAnother() > 0) : ?> <span>X</span> <?php else : ?> <span>Y</span> <?php endif; ?> </div>
If you know that the use of short tags will be enabled on the server, for simplicity you can also use them (not recommended in XML and XHTML). With short tags, you can simply open your PHP part with <? and close it with ?> . In addition, <?=$var?> Is a shorthand for repeating something.
First example with short tags:
<div id="fos"><?=$data->getWhatever()?></div>
You need to know where you use line breaks and spaces. The browser will receive the same text that you write (except for parts of PHP). What I mean:
Writing this code:
<?php echo '<img src="x.jpg" alt="" />'; echo '<img src="y.jpg" alt="" />'; ?>
not equivalent to this:
<img src="x.jpg" alt="" /> <img src="y.jpg" alt="" />
Because in the second you have the actual \n between the img elements, which will be translated by the browser as a space character and displayed as the actual space between the images, if they are embedded.