Forum Moderators: coopster
A class is an "object" that can contain "methods" (basically functions with some special properties) and "properties" (basically variables, but contained within the class so that they don't override variable names.
For instance...
//class built for PHP 4
class Dog
{
var $hairColor;
var $hairLength;
function Dog($hairColor, $hairLength)
{
$this->hairColor = $hairColor;
$this->hairLength = $hairLength;
}
}
In your code, to create a new Dog, you would then use...
$dog1 = new Dog("brown", "1 inch");
$dog2 = new Dog("black", "1 inch");
//Uh-oh, dog 2's hair grew.
$dog2->hairLength = "2 inches";
//dog 1 got much older and his hair turned white...
$dog1->hairColor = "white";
[edited by: WesleyC at 7:23 pm (utc) on Aug. 10, 2007]