3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class ok { public function t() { $this->replacer( '*' ); return preg_replace_callback( '/(t)/', array( $this, 'replacer'), 'this is a simple test' ); } private function replacer( $input ) { static $cache = '-'; if ( ! is_array( $input ) ) { $cache = $input; } else { return $cache . $input[1] . $cache; } } } class buggyphp extends ok {} class buggyphptoo extends ok { public function t() { return parent::t(); } } $buggy = new buggyphp(); echo 'Result buggyphp: ' . $buggy->t(); echo "\n"; $buggy = new buggyphptoo(); echo 'Result buggyphptoo: ' . $buggy->t(); echo "\n"; $a = new ok(); echo 'Result ok: ' . $a->t(); exit();
Output for 5.0.4 - 5.2.6, 5.3.0 - 7.1.0
Result buggyphp: -t-his is a simple -t-es-t- Result buggyphptoo: -t-his is a simple -t-es-t- Result ok: *t*his is a simple *t*es*t*
Output for 5.0.0 - 5.0.3, 5.2.7 - 5.2.17
Result buggyphp: *t*his is a simple *t*es*t* Result buggyphptoo: *t*his is a simple *t*es*t* Result ok: *t*his is a simple *t*es*t*
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/qNuVd on line 3
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/qNuVd on line 3
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/qNuVd on line 3
Process exited with code 255.