C++/Python guy here.
I need to compare two php-arrays containig user-defined classes.
class Point
{
var $x;
var $y;
function _construct($x_, $y_)
{
$this -> x = $x_;
$this -> y = $y_;
}
}
$mas1 = array(new Point(0,1),new Point(0,1),new Point(0,1));
$mas2 = array(new Point(0,1),new Point(0,1),new Point(0,1));
if (array_diff($mas1,$mas2) == array())
{
echo "they're equal\n";
}
i got "Catchable fatal error: Object of class Point could not be converted to string". When i tried to use simple
if ($mas1 == $mas2)
i got False.
Questions: 1) is there way to overload comparison operator for my class Point 2) how to compare two arrays containing user-defined classes correctly?
Thank you.
I use php 5.2.11