I'm trying to print an output, but it comes out before the HTML code, so i've placed ob_start and ob_get_clean functions but now it's not printing anything.
Code:
Code: Select all
<?php
class main_menuErr extends Exception
{
function __construct()
{
}
}
class mainErr extends Exception
{
function __construct()
{
Exception::__construct();
}
}
class main_menu
{
private $tpl = 'templates/desktop/tpl/main_menu.tpl';
function load()
{
global $DB;
ob_start();
$DB -> query("select * from `main_menu`");
while($DB -> fetch())
{
if(!($handle = @fopen($this ->tpl,"r")))
throw new mainErr();
$file = fread($handle, filesize($this -> tpl));
$file = str_replace('<%title%>',$DB['title'],$file);
$file = str_replace('<%image%>',$DB['image'],$file);
$file = str_replace('<%width%>',$DB['width'],$file);
$file = str_replace('<%height%>',$DB['height'],$file);
$file = str_replace('<%left%>',$DB['left'],$file);
$file = str_replace('<%desc%>',$DB['description'],$file);
$file = str_replace('<%module%>','modules/'.$DB['module'],$file);
$file = str_replace('<%top%>',$DB['top'],$file);
$file = str_replace('<%max%>',$DB['max'],$file);
print $file;
fclose($handle);
}
return(ob_get_clean());
}
}
try
{
$main_menu = new main_menu;
$main_menu -> load();
}
catch(main_menuErr $err)
{
print $err -> getMessage();
}
?>Thanks in advance, Tal.