Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save muhamed-didovic/8b0e9f208ab68cd04692 to your computer and use it in GitHub Desktop.

Select an option

Save muhamed-didovic/8b0e9f208ab68cd04692 to your computer and use it in GitHub Desktop.
<?php
class Foo
{
private $private;
public function __construct($value)
{
$this->private = $value;
}
public function getOther(Foo $object)
{
return $object->private;
}
}
$foo1 = new Foo('foo1');
$foo2 = new Foo('foo2');
echo $foo1->getOther($foo2); // outputs 'foo2'
<?php
class Foo
{
// ...
public function equals(Foo $other)
{
return $this->private === $other->private;
}
}
// ...
echo $foo1->equals($foo2) ? 'Equal' : 'Different';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment