3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_field($soc, $opt) { return "blah-$soc-blah"; } function get_template_directory_uri() { return 'https://example.com'; } $socials = ['facebook', 'twitter', 'instagram']; $templateDirectory = get_template_directory_uri(); foreach ($socials as $social) { $socialHref = trim(get_field($social, 'option')); if (strlen($socialHref)) { $socialLinks[] = sprintf('<a class="social-link ie9" href="%s" target="_blank" rel="noopener"><img src="%s/svg/%s.svg" alt="%s Icon"></a>', $socialHref, $templateDirectory, $social, ucfirst($social) ); } } if (isset($socialLinks)) { echo '<div class="social-media--icons">' , "\n\t" , implode("\n\t", $socialLinks) , "\n" , '</div>'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 29
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 28
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 28
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 41
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 29
filename:       /in/f1Utl
function name:  (null)
number of ops:  42
compiled vars:  !0 = $socials, !1 = $templateDirectory, !2 = $social, !3 = $socialHref, !4 = $socialLinks
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, <array>
   10     1        INIT_FCALL                                               'get_template_directory_uri'
          2        DO_FCALL                                      0  $6      
          3        ASSIGN                                                   !1, $6
   11     4      > FE_RESET_R                                       $8      !0, ->29
          5    > > FE_FETCH_R                                               $8, !2, ->29
   12     6    >   INIT_FCALL                                               'trim'
          7        INIT_FCALL                                               'get_field'
          8        SEND_VAR                                                 !2
          9        SEND_VAL                                                 'option'
         10        DO_FCALL                                      0  $9      
         11        SEND_VAR                                                 $9
         12        DO_ICALL                                         $10     
         13        ASSIGN                                                   !3, $10
   13    14        STRLEN                                           ~12     !3
         15      > JMPZ                                                     ~12, ->28
   14    16    >   INIT_FCALL                                               'sprintf'
         17        SEND_VAL                                                 '%3Ca+class%3D%22social-link+ie9%22+href%3D%22%25s%22+target%3D%22_blank%22+rel%3D%22noopener%22%3E%3Cimg+src%3D%22%25s%2Fsvg%2F%25s.svg%22+alt%3D%22%25s+Icon%22%3E%3C%2Fa%3E'
   15    18        SEND_VAR                                                 !3
         19        SEND_VAR                                                 !1
         20        SEND_VAR                                                 !2
         21        INIT_FCALL                                               'ucfirst'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                         $14     
         24        SEND_VAR                                                 $14
         25        DO_ICALL                                         $15     
   14    26        ASSIGN_DIM                                               !4
   15    27        OP_DATA                                                  $15
   11    28    > > JMP                                                      ->5
         29    >   FE_FREE                                                  $8
   19    30        ISSET_ISEMPTY_CV                                         !4
         31      > JMPZ                                                     ~16, ->41
   20    32    >   ECHO                                                     '%3Cdiv+class%3D%22social-media--icons%22%3E'
         33        ECHO                                                     '%0A%09'
         34        INIT_FCALL                                               'implode'
         35        SEND_VAL                                                 '%0A%09'
         36        SEND_VAR                                                 !4
         37        DO_ICALL                                         $17     
         38        ECHO                                                     $17
         39        ECHO                                                     '%0A'
         40        ECHO                                                     '%3C%2Fdiv%3E'
   21    41    > > RETURN                                                   1

Function get_field:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1Utl
function name:  get_field
number of ops:  7
compiled vars:  !0 = $soc, !1 = $opt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        ROPE_INIT                                     3  ~3      'blah-'
          3        ROPE_ADD                                      1  ~3      ~3, !0
          4        ROPE_END                                      2  ~2      ~3, '-blah'
          5      > RETURN                                                   ~2
    4     6*     > RETURN                                                   null

End of function get_field

Function get_template_directory_uri:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1Utl
function name:  get_template_directory_uri
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > RETURN                                                   'https%3A%2F%2Fexample.com'
    7     1*     > RETURN                                                   null

End of function get_template_directory_uri

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.63 ms | 1407 KiB | 23 Q