Re: Comparing objects on PHP5
| From: | Derick Rethans | Date: | Sun, 09 May 2004 17:45:13 +0000 |
| Subject: | Re: Comparing objects on PHP5 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9770@lists.php.net to get a copy of this message | ||
On Sun, 9 May 2004, Andi Gutmans wrote:
> Did you check HEAD? I fixed something to do with the comparison. if it
> still doesn't work please let me know.
Shouldn't this example return "1\n1" ?
<?php
class Country {
function set_name($name) {
$this->name = $name;
}
}
$jurop = new Country;
$dutchieland = new Country;
$dutchieland->set_name('The Netherlands');
echo (int) $jurop, "\n";
echo (int) $dutchieland, "\n";
And this, shouldn't return anything, right?
<?php
class Country {
var $area;
function Country($area) {
$this->area = $area;
}
}
$deutschland = new Country('West Europe');
$die_schweiz = new Country('West Europe');
$norway = new Country('Scandinavia');
if ($deutschland == $die_schweiz) {
echo "Deutschland ist die Schweiz.\n";
}
if ($deutschland == $norway) {
echo "Deutschland er Norway.\n";
}
This *was* working fine last week, except that I got notices like:
Notice: Object of class Country could not be converted to integer in -
on line 13
or the like.
regards,
Derick