3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class TheParent { public function parentPublic() { return __METHOD__; } protected function parentProtected() { return __METHOD__; } private function parentPrivate() { return __METHOD__; } public function isCallable($subject) { return is_callable(array($this, $subject)); } public function call($subject) { return $this->$subject(); } } class TheChild extends TheParent { public function childPublic() { return __METHOD__; } protected function childProtected() { return __METHOD__; } private function childPrivate() { return __METHOD__; } public function isChildCallable($subject) { return is_callable(array($this, $subject)); } } $theParent = new TheParent; $subjects = array( 'parentPublic', 'parentProtected', 'parentPrivate', ); var_dump('Parent#isCallable():' $theParent); foreach ($subjects as $subject) { var_dump( $subject, $theParent->isCallable($subject) ); } $theChild = new TheChild; $subjects = array_merge( array( 'childPublic', 'childProtected', 'childPrivate', ), $subjects ); var_dump('Child#isCallable():' $theParent); foreach ($subjects as $subject) { var_dump( $subject, $theChild->isCallable($subject) ); } var_dump('Child#isChildCallable():' $theParent); foreach ($subjects as $subject) { var_dump( $subject, $theChild->isChildCallable($subject) ); }
based on kuPBv
Output for 5.4.0 - 5.4.35
Parse error: syntax error, unexpected '$theParent' (T_VARIABLE) in /in/1WEVf on line 23
Process exited with code 255.
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/1WEVf on line 23
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_VARIABLE in /in/1WEVf on line 23
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/1WEVf 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/1WEVf 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/1WEVf on line 4
Process exited with code 255.