Re: output result of one function in another

From: Date: Thu, 09 Nov 2000 11:02:35 +0000
Subject: Re: output result of one function in another
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-24607@lists.php.net to get a copy of this message
In article <20001102133215.A67281@ipo.vpaa.asu.edu>, webmaster@ipo.asu.edu wrote: I think you want something more like this: class MainPage { var $title; var $header; var $footer; function FormatPage($title, $header, $footer){ print(..); "" "" "" print("<table><tr><td>$footer</td></tr></table>"); "" } } class EndPage extends MainPage { function Footer() { $footerText = "stuff"; $footerText .= "more stuff"; .... return $footerText; } } $pageObject = new MainPage(); $footerObject = new EndPage(); $footerText = $footerObject->Footer(); $pageObject->FormatPage($title,$header,$footerText); I didn't try this out, but give a shot and see if it's what you want. Jeff Warrington > Greetings, > > A question concerning classes and functions, still learning about these. > Anyway, the main class has one function and the purpose of this function > is to create a template for nearly all the pages on our website. The > function passes two variables for the page title and heading fine. > > class MainPage { > > var $title; var $header; var $footer; > > function FormatPage($title, $header, $footer){ > > print(..); > "" > "" > "" > > print("<table><tr><td>$footer</td></tr></table>"); > "" > } > } > > class EndPage extends MainPage { > > function Footer() { > print(..); > "" > "" > "" > } > } > > > Page which calls the functions > > $footer = new EndPage(); > $page = new FormatPage(); > $page-> MainPage($title, $header, $footer); > $footer->Footer(); > > > The problem arises with the 3rd variable, is from a subclass of the main > class which has a function that form a page footer. From above I attempt > to assign the output of the Footer() function to the variable $footer > and place it in a cell in the table. The script prints "Object" where > the footer should be. It does print the footer but the output is after > the output of the MainPage function. > > Any ideas on how to solve this problem? I've tried a number of different > things and there's something(probably something very simple) that I'm > missing. > > Thanks. >

« previous php.general (#24607) next »