3v4l.org

run code in 200+ php & hhvm versions
<?php class toStr { private $str; public function __construct( $str ) { $this->str = $str; } public function __toString() { return $this->str; } } $a = new toStr( 'hi' ); var_dump( $a === 'hi' ); var_dump( $a == 'hi' ); var_dump( 'hi' === $a ); var_dump( 'hi' == $a );
based on j5NXO
Output for 7.1.25 - 7.3.3
bool(false) bool(true) bool(false) bool(true)