3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Profile { private $active = false; public function activate() { $this->active = true; } public function isActive() { return $this->active; } } interface Event { function execute($object); } class ProfileWasActivated implements Event { public function execute($profile) { $profile->activate(); } } class EventDomainObjectLoader { public static function load($object, array $events) { foreach($events as $event) { $event->execute($object); } return $object; } } EventDomainObjectLoader::load(new Profile(), [new ProfileWasActivated()]); var_dump($profile->isActive());
based on dh0pp
Output for 7.0.5 - 7.1.0
Notice: Undefined variable: profile in /in/o6T2t on line 35 Fatal error: Uncaught Error: Call to a member function isActive() on null in /in/o6T2t:35 Stack trace: #0 {main} thrown in /in/o6T2t on line 35
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: profile in /in/o6T2t on line 35 Fatal error: Uncaught Error: Call to a member function isActive() on unknown in /in/o6T2t:35 Stack trace: #0 {main} thrown in /in/o6T2t on line 35
Process exited with code 255.
Output for 5.6.7 - 5.6.28
Notice: Undefined variable: profile in /in/o6T2t on line 35 Fatal error: Call to a member function isActive() on null in /in/o6T2t on line 35
Process exited with code 255.
Output for 5.4.0 - 5.5.35
Notice: Undefined variable: profile in /in/o6T2t on line 35 Fatal error: Call to a member function isActive() on a non-object in /in/o6T2t on line 35
Process exited with code 255.
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/o6T2t on line 34
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/o6T2t on line 26
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/o6T2t on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/o6T2t on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/o6T2t on line 4
Process exited with code 255.