Skip to content

Instantly share code, notes, and snippets.

@fixlr
Created August 16, 2011 13:49
Show Gist options
  • Save fixlr/1149122 to your computer and use it in GitHub Desktop.
Save fixlr/1149122 to your computer and use it in GitHub Desktop.
<?php
class FooThing
{
var $message = 'foo';
function to_s() {
return $message;
}
function __toString() {
return $message;
}
}
$foo = new FooThing();
echo $foo->to_s(); // prints "message"
('foo' == $foo->to_s()) // evaluates true
echo $foo; // prints "message"
('foo' == $foo) // evaluates false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment