<?php ob_start(); ?> <div> <p>Here go your view</p> </div> <?php $content = ob_get_clean(); //now you can echo the content in base.php ?> <?php require( __DIR__ . './base.php'); ?>