3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Auth { function __construct($foo) { $this->foo = $foo; } function __toString() { return "Basic $foo"; } } $auth = new Auth('1234'); $bar = (string)$auth; echo $bar;
Output for 5.2.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Notice: Undefined variable: foo in /in/6FNXA on line 12 Basic
Output for 5.0.0 - 5.1.6
Object id #1
Output for 4.3.0 - 4.4.9
Notice: Object to string conversion in /in/6FNXA on line 19 Object