3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $pattern = '/\[CODE\](.*)\[\/CODE\]/'; $replacement = function($m) { return htmlentities($m[0]); }; $subject = <<<EOT <html> <body> <div id="box1">[CODE]<span class="test">Hello World</span>[/CODE]</div> <div id="box2">[CODE]<strong class="test2">Nice to meet you!</strong>[/CODE]</div> </body> </html> EOT; echo preg_replace($pattern, $replacement, $subject);
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Object of class Closure could not be converted to string in /in/6KK9G on line 15
Process exited with code 255.
Output for 5.3.18 - 7.0.20
Catchable fatal error: Object of class Closure could not be converted to string in /in/6KK9G on line 15
Process exited with code 255.