3v4l.org

run code in 300+ PHP versions simultaneously
<?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 );
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.29, 8.0.0 - 8.0.19, 8.1.0 - 8.1.6
bool(false) bool(true) bool(false) bool(true)

preferences:
32.94 ms | 409 KiB | 5 Q