That's a good rule of thumb for deciding whether to create a function. If you expect to reuse a section of code, you should probably make it into a function.
Classes are a little different. A class isn't just a bunch of functions that you plan to use on the same page. It's a group of related variables and functions that all describe or manipulate a certain object.
Let's say you have a form page with some text boxes displayed in a table. You decide to create a class like this:
class TextBox {
var $name;
var $size;
var $defaultval;
function TextBox(name, size, defaultval="")
{
$this->name = $name;
$this->size = $size;
$this->defaultval=$defaultval;
}
function printCell()
{
echo "<td><input type=\"text\" name=\"$name\" size=\"$size\" value=\"$defautval\"></td>";
}
}
Next it occurs to you that it would be nice to have a function to print labels for each text box. Should that be in your class? Do labels describe text boxes in some way? I think they do. A label describes the way a user sees a text box. So it makes sense to add it to the class.
Suppose you have another function to print a title at the top of your form page. Does a form title describe a text box? Not really. It describes the form that contains text boxes, but it doesn't describe the text boxes themselves. So that function doesn't belong in your class.
It's not really about reusability. You may have 50 pages that all contain forms, but the form title still wouldn't belong in the TextBox class. It might make sense to put your TextBox class and print_form_title() function in the same include file, but form titles are not part of text boxes, so they don't belong in the TextBox class.
HTH,
Beth