I have two files index.php and template.html. In the template file I have a div, which contains some PHP code inside. What I am trying to achieve is to pull the div from template including everything inside and insert it to my main index page. I managed to do so, but only if there is no PHP code inside the div. If however there is any PHP included I see something like this "saveHTML($snippet[1]) ?>;" instead of full PHP code block. Could you please explain the reason why I am not able to move the div including PHP codes.
index.php file
<?php
//some basic stuff such as new DOMDocument(); loadHTMLFile and so on
$post = $posts->query("//div[contains(@class, 'post')]");
?>
<body>
<?php echo $templates->saveHTML($post[0]);?>
</body>
template.html file
<div class="post">
<?php echo $examples->saveHTML($snippet[1]) ?>;
</div>