Beyond The Basics?
name = $name;
$this->lname = $lname;
Person::$id++;
}
function __clone()
{
$this->increment(); /* we're cloning, creating another person, so increase count */
}
function fullname()
{
return $this->name . " " . $this->lname;
}
static function increment()
{
self::$id++; /* another way to mean Person:: */
}
}
class Employee extends Person
{
static function oneup()
{
parent::increment(); /* refer to parent's stuff */
}
};
$person = new Person("Kyle", "Broflovski");
echo $person->fullname() . "
\n";
$me = clone $person;
$me->lname = "K";
echo $me->fullname() . "
\n";
echo "total ids: " . Person::$id . "
\n";
?>
== is like memcmp in C, it compares whole classes and attributes
=== is like == in C, simply comparing references