3v4l.org

run code in 300+ PHP versions simultaneously
<?php function prepareForOutput($content, $exclude=[]) { $replacements = [ "\r" => '\r', "\n" => '\n', "\t" => '\t', " " => '·', ]; if (stripos(PHP_OS, 'WIN') === 0 && PHP_VERSION_ID < 70100) { // Do not replace spaces on old PHP on Windows. // Printing Unicode characters like '·' to Windows console only works since PHP 7.1. unset($replacements[" "]); } $replacements = array_diff_key($replacements, array_fill_keys($exclude, true)); // Colour runs of invisible characters. $match = implode('', array_keys($replacements)); $content = preg_replace("/([$match]+)/", "\033[30;1m$1\033[0m", $content); $content = strtr($content, $replacements); return $content; } for ($i = 0; $i < 10000; $i++) { prepareForOutput('{echo 1;}', ["\r"]); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 2
Branch analysis from position: 9
Branch analysis from position: 2
filename:       /in/7NQUU
function name:  (null)
number of ops:  10
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->7
   30     2    >   INIT_FCALL                                               'prepareforoutput'
          3        SEND_VAL                                                 '%7Becho+1%3B%7D'
          4        SEND_VAL                                                 <array>
          5        DO_FCALL                                      0          
   29     6        PRE_INC                                                  !0
          7    >   IS_SMALLER                                               !0, 10000
          8      > JMPNZ                                                    ~4, ->2
   31     9    > > RETURN                                                   1

Function prepareforoutput:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
Branch analysis from position: 10
filename:       /in/7NQUU
function name:  prepareForOutput
number of ops:  45
compiled vars:  !0 = $content, !1 = $exclude, !2 = $replacements, !3 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
    5     2        ASSIGN                                                   !2, <array>
   11     3        INIT_FCALL                                               'stripos'
          4        SEND_VAL                                                 'Linux'
          5        SEND_VAL                                                 'WIN'
          6        DO_ICALL                                         $5      
          7        IS_IDENTICAL                                     ~6      $5, 0
          8      > JMPZ_EX                                          ~6      ~6, ->10
          9    >   BOOL                                             ~6      <false>
         10    > > JMPZ                                                     ~6, ->12
   14    11    >   UNSET_DIM                                                !2, '+'
   17    12    >   INIT_FCALL                                               'array_diff_key'
         13        SEND_VAR                                                 !2
         14        INIT_FCALL                                               'array_fill_keys'
         15        SEND_VAR                                                 !1
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $7      
         18        SEND_VAR                                                 $7
         19        DO_ICALL                                         $8      
         20        ASSIGN                                                   !2, $8
   20    21        INIT_FCALL                                               'implode'
         22        SEND_VAL                                                 ''
         23        INIT_FCALL                                               'array_keys'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                         $10     
         26        SEND_VAR                                                 $10
         27        DO_ICALL                                         $11     
         28        ASSIGN                                                   !3, $11
   21    29        INIT_FCALL                                               'preg_replace'
         30        ROPE_INIT                                     3  ~14     '%2F%28%5B'
         31        ROPE_ADD                                      1  ~14     ~14, !3
         32        ROPE_END                                      2  ~13     ~14, '%5D%2B%29%2F'
         33        SEND_VAL                                                 ~13
         34        SEND_VAL                                                 '%1B%5B30%3B1m%241%1B%5B0m'
         35        SEND_VAR                                                 !0
         36        DO_ICALL                                         $16     
         37        ASSIGN                                                   !0, $16
   23    38        INIT_FCALL                                               'strtr'
         39        SEND_VAR                                                 !0
         40        SEND_VAR                                                 !2
         41        DO_ICALL                                         $18     
         42        ASSIGN                                                   !0, $18
   25    43      > RETURN                                                   !0
   27    44*     > RETURN                                                   null

End of function prepareforoutput

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.28 ms | 1011 KiB | 21 Q