Thread: OOP Problem
View Single Post
Old 09-17-2007, 01:24 PM   #3 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I see the problem here. As you are including the files in your class itself, you're correct in that it inherits it, but it retains its scope. Therefore, take header.php as our example, because it is being included in the getHeader() function it will be included correctly, but be classed as part of the class.

Thus, in header.php you can still call the functions in your Layout class, but instead of using the object itself that you created when initiating your class, in your example, $System->Layout, it would simply by $this.

Wrong:

PHP Code:
<?php echo $System->Config->showSiteName();?>
Right:

PHP Code:
<?php echo $this->showSiteName();?>
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote