Allright, let's get this step by step..
class Ford {
public $founder = "Henry Ford",
$headquarters = "Detroit",
$employees = 164000;
}
So here's a Ford Class with 3 public variables all already defined.
Then, inside your class Ford you have a function called produces.
public function produces($car) {
return $car->producer == $this;
}
This will return 1...we'll get at it soon enough.
Another class, nammed Car with 2 public variables but this time it doesnt equal to anything.
class Car {
public $color,
$producer;
}
Then, you have
$ford = new Ford();
$car = new Car();
So you set ford variable ($ford) as instance of Ford, and $car as instance of your class Car. This is okay to call whats inside of it.
$car->color = "Blue";
$car->producer = $ford;
So, NOW you define whats inside $color and $producer. Everythings works fine so far.
And then you have this :
$car->color = "Blue";
$car->producer = $ford;
You define what $color is : a string 'Blue' and your $car->producer (which is the variable $producer) is now the instance of your class Ford. Because don't forget it, you already defined what's inside ford variable :
$ford = new Ford();
So when you do
echo $ford->produces($car)
you put your $car = new Car() as argument
and you return $car->producer (which is equal to $ford cause you defined it) is equal to $this, which is your same object as $car->producer...So the answer is yes, it gives you a 1 for true.
Then you have
echo $ford->founder;
And it will echo out Henry Ford string, defined in Ford class as public variable.
It's simply because you can't say echo $founder, because $founder variable only exist in Ford class. This is all about scoping. So you do $ford->founder; to get the variable!
Last thing, echo $ford->produces(); and echo $ford->founder; is not the same thing you are calling inside Ford Classes. Founder has no () so it's only a variable ;)
If you have any other questions, just ask.
(Oh yeah and sorry, I did little change in your script just to see easier variables.