RE: [PHP] functions/methods and what they should return

From: Date: Wed, 20 Aug 2003 22:15:26 +0000
Subject: RE: [PHP] functions/methods and what they should return
Groups: php.general 
Request: Send a blank email to php-general+get-160252@lists.php.net to get a copy of this message
Dan Anderson <mailto:dan@mathjunkies.com> on Wednesday, August 20, 2003 3:04 PM said: > You want to break off things into as many functions and components as > possible. Hmm.. Ok. So right now I've got this (psuedo code): function displayAttributes($id) { // query db // store results in array // perform logic that builds HTML string // return HTML string } But instead you think I should do this: function GetAttributes($id) { // query db // get records // return record array } function BuildAttributes($id) { $attributes = GetAttributes($id); // format $attributes // return HTML string } Is that what you're suggesting? > The idea is that if you want to change the way tables are > displayed with the data, for instance, you can't break the way data is > queried. I don't understand this exactly. What do you mean by "can't break the way data is queried"? > I usually have a bunch of different files like > "inc.function.something.php" and use lots of require_once() > statements. Hmm.. Although this sounds like a good idea at first, it seems like it would get pretty complicated really fast. Am I missing something? Thanks. Chris.

« previous php.general (#160252) next »