3v4l.org

run code in 500+ PHP versions simultaneously
<?php $doc_comment = "test\r\nreturns\rare\r\nreplaced as expected"; print "\n\npreg_replace (broken):\n"; var_dump(preg_replace('/\r\n|\r/', '\n', $doc_comment)); print "\n\npreg_replace (fixed):\n"; var_dump(preg_replace('/\r\n|\r/', "\n", $doc_comment)); print "\n\nstr_replace:\n"; var_dump(str_replace(['\r\n', '\r'], ['\n', '\n'], $doc_comment)); print "\n\nstr_replace (double quotes):\n"; var_dump(str_replace(["\r\n", "\r"], "\n", $doc_comment));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hTIOV
function name:  (null)
number of ops:  26
compiled vars:  !0 = $doc_comment
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, 'test%0D%0Areturns%0Dare%0D%0Areplaced+as+expected'
    4     1        ECHO                                                         '%0A%0Apreg_replace+%28broken%29%3A%0A'
    5     2        INIT_FCALL                                                   'var_dump'
          3        FRAMELESS_ICALL_3                preg_replace        ~2      '%2F%5Cr%5Cn%7C%5Cr%2F', '%5Cn'
          4        OP_DATA                                                      !0
          5        SEND_VAL                                                     ~2
          6        DO_ICALL                                                     
    6     7        ECHO                                                         '%0A%0Apreg_replace+%28fixed%29%3A%0A'
    7     8        INIT_FCALL                                                   'var_dump'
          9        FRAMELESS_ICALL_3                preg_replace        ~4      '%2F%5Cr%5Cn%7C%5Cr%2F', '%0A'
         10        OP_DATA                                                      !0
         11        SEND_VAL                                                     ~4
         12        DO_ICALL                                                     
    8    13        ECHO                                                         '%0A%0Astr_replace%3A%0A'
    9    14        INIT_FCALL                                                   'var_dump'
         15        FRAMELESS_ICALL_3                str_replace         ~6      <array>, <array>
         16        OP_DATA                                                      !0
         17        SEND_VAL                                                     ~6
         18        DO_ICALL                                                     
   10    19        ECHO                                                         '%0A%0Astr_replace+%28double+quotes%29%3A%0A'
   11    20        INIT_FCALL                                                   'var_dump'
         21        FRAMELESS_ICALL_3                str_replace         ~8      <array>, '%0A'
         22        OP_DATA                                                      !0
         23        SEND_VAL                                                     ~8
         24        DO_ICALL                                                     
         25      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
127.02 ms | 477 KiB | 8 Q