RE: [PHP] functions/methods and what they should return
| From: | Ray Hunter | Date: | Wed, 20 Aug 2003 22:29:03 +0000 |
| Subject: | RE: [PHP] functions/methods and what they should return | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-160255@lists.php.net to get a copy of this message | ||
> function GetAttributes($id)
> {
> // query db
>
> // get records
>
> // return record array
> }
>
> function BuildAttributes($id)
> {
> $attributes = GetAttributes($id);
>
> // format $attributes
>
> // return HTML string
> }
That is a good way...you have the functions only doing what they need to
do. Thus splitting up some of the logic and presentation. In the
GetAttributes function you could do any filtering...but mainly you dont
want to do any presentation because u can now reuse that function other
places.
--
BigDog