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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.