<?php class Index { public function getBody() { echo $this->getMenu(); } private function getMenu() { $menu = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/menu.php'); return $this->replaceStringMenu($menu); } private function replaceStringMenu($menu) { $main = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/main.php'); return str_replace("%menu%", $menu, $main); } } ?> I call on the main getBody() , and the code from menu.php processed as html , what can I do to make it work like php ?
Update
With include, it processes the code, only I change the expression of the menu block, and the result is displayed just at the top of the page.
<?php require_once '/index.class.php'; $obj = new Index; $obj->getBody(); ?>