3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $source_code = "\nprint('Hello\nTest 123\nWorld')\n"; $source_code = "x=input()\nprint('Hello\nWorld')\n"; $match = preg_match('/(["\'])(.*)\1/s', $source_code, $matches); if ($match) { $text = $matches[2]; $text = str_replace("\n", '\\\\n', $text); $source_code = preg_replace('/(.*)((["\']).*\3)(.*)/s', '$1$3' . addslashes($text) . '$3$4', $source_code); } var_dump($source_code);

preferences:
152.57 ms | 408 KiB | 5 Q