I run php code inside HTML code but it seems that php code loaded then HTML.
My HTML:
<div id ="main-Body">
<?php $this->load($content);?> //$content: link file
</div>
function load:
public function load($view,$data =[])
{
extract($data);
ob_start();
require_once PATH_APPLICATION . '/views/' . $view . '.php';
$content = ob_get_contents();
ob_end_clean();
$this->loadedContent[] = $content;
}
public function Show()
{
foreach($this->loadedContent as $html)
{
echo $html;
}
}
A result on the Browser:
<!--It shows $this->load($content) here-->
<div id ="main-Body">
<!--nothing here-->
</div>
EDIT: if I put the following code into $content file
<div id ="main-Body">
</div>
Then show:
<?php $this->load($content);?> //$content: link file
It is nothing wrong.
< divspace is really exist or it just copy paste issue ?echoorprintthe output?