3v4l.org

run code in 300+ PHP versions simultaneously
<?php function coalesce($default, &...$args) { return current(array_filter($args)) ?: $default; } $empty1 = []; $empty2 = ''; $value1 = 'not empty!'; echo coalesce('default', $empty1, $undefined, $empty2); echo coalesce('default', $empty1, $undefined, $value1, $empty2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SDLSF
function name:  (null)
number of ops:  19
compiled vars:  !0 = $empty1, !1 = $empty2, !2 = $value1, !3 = $undefined
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, ''
   10     2        ASSIGN                                                   !2, 'not+empty%21'
   12     3        INIT_FCALL                                               'coalesce'
          4        SEND_VAL                                                 'default'
          5        SEND_REF                                                 !0
          6        SEND_REF                                                 !3
          7        SEND_REF                                                 !1
          8        DO_FCALL                                      0  $7      
          9        ECHO                                                     $7
   13    10        INIT_FCALL                                               'coalesce'
         11        SEND_VAL                                                 'default'
         12        SEND_REF                                                 !0
         13        SEND_REF                                                 !3
         14        SEND_REF                                                 !2
         15        SEND_REF                                                 !1
         16        DO_FCALL                                      0  $8      
         17        ECHO                                                     $8
         18      > RETURN                                                   1

Function coalesce:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SDLSF
function name:  coalesce
number of ops:  12
compiled vars:  !0 = $default, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
    4     2        INIT_FCALL                                               'current'
          3        INIT_FCALL                                               'array_filter'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                         $3      
          8        JMP_SET                                          ~4      $3, ->10
          9        QM_ASSIGN                                        ~4      !0
         10      > RETURN                                                   ~4
    5    11*     > RETURN                                                   null

End of function coalesce

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.4 ms | 1399 KiB | 19 Q