I can't figure out how to say what I'm talking about which is a big part of why I'm stuck. In PHP I often see code like this
html
<?php
language construct that uses brackets {
some code;
?>
more html
<?php
some more code;
}
?>
rest of html
Is there any name for this? Having seen this lead me to try it out so here is a concrete example whose behavior doesn't make sense to me
<div id="content">
<ul id="nav">
<?php
$path = 'content';
$dir = dir($path);
while(false !== ($file = $dir->read())) {
if(preg_match('/.+\.txt/i', $file)) {
echo "<li class=\"$file\">$file</li>";
?>
</ul>
<?php
echo "<p class=\"$file\">" . file_get_contents($path . '/' . $file) . '</p>';
}
}
?>
</div>
Which outputs roughly <div><ul><li></li></ul><li></li><p></p>...</div>
instead of <div><ul><li></li>...</ul><p></p>...</div>
, which is what I thought would happen and what I want to happen. To make it clearer I want the <li>
inside the <ul>
and the <p>
inside the <div>
. Yes, I know there is an easy solution but I was wondering if there is a way to do it with the technique I am looking for a name for.