3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo <<<HEREDOC TEST HEREDOC; // Because you are presumably rtrim()ing the input, if the last statement in the file is a heredoc/nowdoc // it results in a syntax error, because the trailing lf is part of the terminator. This comment will make // it work. Just do $input = rtrim($input) . "\n"; to fix. Strictly you should keep the trailing line break // anyway because of https://stackoverflow.com/a/729795/889949
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
TEST

preferences:
69.87 ms | 1373 KiB | 4 Q