Class calling itself? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Class calling itself?

SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
Alright, I'm developing an ultra-lightweight PHP class to parse basic XHTML templates and have hit a snag. Some of my templates include other templates to reduce file-size and repetitive code, as well as allowing things like menus to be modified by editing one single file instead of a menu on every page.

What happens is when my template-parser attempts to replace tags in a sub-template, the page never loads at all. It just completely stops working. I get nothing from the server, even if I wrap every line with "echo" statements.

Here is the function in question:
[code]
//Public method to replace all tags on the page with their respective data
public function ReplaceTags($Tags = array())
{
$SubPage = new Page(NULL);

if(sizeof($Tags > 0))
{
foreach($Tags as $Tag => $Data)
{
//$Data = (file_exists($Data)) ? $this->Parse($Data) : $Data;
if(file_exists($Data))
{
if($SubPage->LoadTemplate($Data))
{
if($SubPage->ReplaceTags($Tags))
$Data = $SubPage->OutputBuffer($Data);
else
$Data = "

Failed to replace tags in template: " . $Data . "

";
}
else
$Data = "

Failed to load sub-template: " . $Data . "

";
}

$this->TempPage = eregi_replace("{" . $Tag . "}", $Data, $this->TempPage);
}
}
else
return false;

return true;
}
[/code]
If I comment out the stuff after checking to see whether or not the file exists, everything works except sub-templates don't get parsed and as such, display funky tags instead of data. The class is called "Page".
-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Comments

  • mac_doggiemac_doggie Posts: 488Member
    sizeof($tags > 1) should be: sizeof($tags) > 1
    ;-)
    -mac-
    mailto:[email protected]
    the Netherlands...
Sign In or Register to comment.