I have wrote a function that should first output a navigation bar, and after include the page content, I have tried to put the include inside a variable, but it doesn't work and I don't know how to do it, can you help me?
here is the code:
class myclass {
function test() {
if($_SESSION['logged_in'] == TRUE) {
$pages = array('news', 'main', 'email', 'switch', 'comments');
$page = "main";
if(isset($_GET['page'])) {
$page = $_GET['page'];
}
//navigation bar
$blah = '<div id="shittynavigationbar"><ul>';
foreach($pages as $url) {
$out .= '<li><a href="/?id=admin&action=$url"';
if($url != $n){
$out .= ' id="active"';
}
$out .= '>' . ucfirst($url) . '</a></li>';
}
$out .= '</ul></div><div id="main">';
//content
if(!in_array(basename($action), $pages)) {
$out .= include('admin/inc/' . $action . '.php');
} else {
$out .= 'page not found';
}
return $out;
} else {
return 'you are not logged in';
}
}
}
$a = new myclass();
echo $a->test();
Thanks in advance