3v4l.org

run code in 300+ PHP versions simultaneously
<?php function tagWrap(string $tag, string $txt = '', ?callable $func = null): string { $txt = $func ? $func($txt) : $txt; if (!strlen($txt)) { return ''; } return sprintf('<%1$s>%2$s</%1$s>', $tag, $txt); } function underline($txt) { return "<u>$txt</u>"; } echo tagWrap('b', 'make me bold') . "\n"; echo tagWrap('b') . "\n"; echo tagWrap('b', func: fn() => 'sneak this text in') . "\n"; echo tagWrap('i', 'underline me too', "underline") . "\n"; echo tagWrap('i', 'encode \'me\'', "htmlentities") . "\n"; echo tagWrap('i', 'make me italic and quote me', fn($txt) => "&quot;$txt&quot;");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NQjhg
function name:  (null)
number of ops:  41
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'tagwrap'
          1        SEND_VAL                                                 'b'
          2        SEND_VAL                                                 'make+me+bold'
          3        DO_FCALL                                      0  $0      
          4        CONCAT                                           ~1      $0, '%0A'
          5        ECHO                                                     ~1
   16     6        INIT_FCALL                                               'tagwrap'
          7        SEND_VAL                                                 'b'
          8        DO_FCALL                                      0  $2      
          9        CONCAT                                           ~3      $2, '%0A'
         10        ECHO                                                     ~3
   17    11        INIT_FCALL                                               'tagwrap'
         12        SEND_VAL                                                 'b'
         13        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
         14        SEND_VAL                                                 ~4
         15        CHECK_UNDEF_ARGS                                         
         16        DO_FCALL                                      0  $5      
         17        CONCAT                                           ~6      $5, '%0A'
         18        ECHO                                                     ~6
   18    19        INIT_FCALL                                               'tagwrap'
         20        SEND_VAL                                                 'i'
         21        SEND_VAL                                                 'underline+me+too'
         22        SEND_VAL                                                 'underline'
         23        DO_FCALL                                      0  $7      
         24        CONCAT                                           ~8      $7, '%0A'
         25        ECHO                                                     ~8
   19    26        INIT_FCALL                                               'tagwrap'
         27        SEND_VAL                                                 'i'
         28        SEND_VAL                                                 'encode+%27me%27'
         29        SEND_VAL                                                 'htmlentities'
         30        DO_FCALL                                      0  $9      
         31        CONCAT                                           ~10     $9, '%0A'
         32        ECHO                                                     ~10
   20    33        INIT_FCALL                                               'tagwrap'
         34        SEND_VAL                                                 'i'
         35        SEND_VAL                                                 'make+me+italic+and+quote+me'
         36        DECLARE_LAMBDA_FUNCTION                          ~11     [1]
         37        SEND_VAL                                                 ~11
         38        DO_FCALL                                      0  $12     
         39        ECHO                                                     $12
         40      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NQjhg
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E > > RETURN                                                   'sneak+this+text+in'
          1*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NQjhg
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $txt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        ROPE_INIT                                     3  ~2      '%26quot%3B'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%26quot%3B'
          4      > RETURN                                                   ~1
          5*     > RETURN                                                   null

End of Dynamic Function 1

Function tagwrap:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
Branch analysis from position: 15
filename:       /in/NQjhg
function name:  tagWrap
number of ops:  24
compiled vars:  !0 = $tag, !1 = $txt, !2 = $func
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      ''
          2        RECV_INIT                                        !2      null
    4     3      > JMPZ                                                     !2, ->9
          4    >   INIT_DYNAMIC_CALL                                        !2
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $3      
          7        QM_ASSIGN                                        ~4      $3
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~4      !1
         10    >   ASSIGN                                                   !1, ~4
    5    11        STRLEN                                           ~6      !1
         12        BOOL_NOT                                         ~7      ~6
         13      > JMPZ                                                     ~7, ->15
    6    14    > > RETURN                                                   ''
    8    15    >   INIT_FCALL                                               'sprintf'
         16        SEND_VAL                                                 '%3C%251%24s%3E%252%24s%3C%2F%251%24s%3E'
         17        SEND_VAR                                                 !0
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $8      
         20        VERIFY_RETURN_TYPE                                       $8
         21      > RETURN                                                   $8
    9    22*       VERIFY_RETURN_TYPE                                       
         23*     > RETURN                                                   null

End of function tagwrap

Function underline:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NQjhg
function name:  underline
number of ops:  6
compiled vars:  !0 = $txt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        ROPE_INIT                                     3  ~2      '%3Cu%3E'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%3C%2Fu%3E'
          4      > RETURN                                                   ~1
   13     5*     > RETURN                                                   null

End of function underline

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.72 ms | 1021 KiB | 20 Q