/ Published in: PHP

Sample which shoows how to compare objects by content.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
interface Comparable_Equals { public function equals(self $other); } class User implements Comparable_Equals { public function equals(self $other) { return $this['id'] == $other['id']; } // other methods } $stancell = User::loadByUsername('stancell'); $user = User::loadById(20); echo $user->equals($stancell) ? 'The same user' : 'Different user';
Comments
