3v4l.org

run code in 300+ PHP versions simultaneously
<?php $line = "line\rwith\nvarious\r\nline endings\n\n"; echo json_encode($line); echo PHP_EOL; echo json_encode(preg_replace('/\R/', PHP_EOL, $line));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5cBcW
function name:  (null)
number of ops:  16
compiled vars:  !0 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'line%0Dwith%0Avarious%0D%0Aline+endings%0A%0A'
    5     1        INIT_FCALL                                               'json_encode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ECHO                                                     $2
    6     5        ECHO                                                     '%0A'
    7     6        INIT_FCALL                                               'json_encode'
          7        INIT_FCALL                                               'preg_replace'
          8        SEND_VAL                                                 '%2F%5CR%2F'
          9        SEND_VAL                                                 '%0A'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $3      
         12        SEND_VAR                                                 $3
         13        DO_ICALL                                         $4      
         14        ECHO                                                     $4
         15      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
132.41 ms | 997 KiB | 15 Q