3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Sample { protected function someProtectedMethod() { echo 'hello world'; } } $x = new Sample(); $g = function() { $this->someProtectedMethod(); }; $g = $g->BindTo($x); $g();
based on jHXWP
Output for 7.1.0 - 7.3.0alpha1
Fatal error: Uncaught Error: Call to protected method Sample::someProtectedMethod() from context 'Closure' in /in/BdneA:12 Stack trace: #0 /in/BdneA(15): Closure->{closure}() #1 {main} thrown in /in/BdneA on line 12
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Call to protected method Sample::someProtectedMethod() from context 'Closure' in /in/BdneA:-1 Stack trace: #0 /in/BdneA(-1): Closure$() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: Call to protected method Sample::someProtectedMethod() from context 'Closure' in /in/BdneA:12 Stack trace: #0 /in/BdneA(15): Closure$() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Call to protected method Sample::someProtectedMethod() from context 'Closure' in /in/BdneA on line 12
Process exited with code 255.