3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<'HTML' <div class="blockImg imgRight"> <img src="customs/2/pictures/home.png"> <figcaption>Une légende</figcaption> </div> HTML; $dom = \Dom\HTMLDocument::createFromString($html, LIBXML_NOERROR | \DOM\HTML_NO_DEFAULT_NS); $xp = new \Dom\XPath($dom); $context = $dom->getElementsByTagName('div')[0]; $classList = $context->classList; if ($classList->contains('blockImg') and $classList->contains('imgRight') || $classList->contains('imgLeft')) { $class = $classList->contains('imgRight') ? 'imgRight' : 'imgLeft'; $src = $xp->evaluate('string(img/@src)', $context); $caption = $xp->evaluate('string(figcaption)', $context); echo $class, PHP_EOL, $src, PHP_EOL, $caption, PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 32
Branch analysis from position: 23
2 jumps found. (Code = 47) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 57
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
Branch analysis from position: 31
Branch analysis from position: 32
filename:       /in/qvvuL
function name:  (null)
number of ops:  58
compiled vars:  !0 = $html, !1 = $dom, !2 = $xp, !3 = $context, !4 = $classList, !5 = $class, !6 = $src, !7 = $caption
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv+class%3D%22blockImg+imgRight%22%3E%0A%09%3Cimg+src%3D%22customs%2F2%2Fpictures%2Fhome.png%22%3E%0A%09%3Cfigcaption%3EUne+l%C3%A9gende%3C%2Ffigcaption%3E%0A%3C%2Fdiv%3E'
   10     1        INIT_STATIC_METHOD_CALL                                  'Dom%5CHTMLDocument', 'createFromString'
          2        SEND_VAR_EX                                              !0
          3        FETCH_CONSTANT                                   ~9      'DOM%5CHTML_NO_DEFAULT_NS'
          4        BW_OR                                            ~10     ~9, 32
          5        SEND_VAL_EX                                              ~10
          6        DO_FCALL                                      0  $11     
          7        ASSIGN                                                   !1, $11
   12     8        NEW                                              $13     'Dom%5CXPath'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $13
   14    12        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         13        SEND_VAL_EX                                              'div'
         14        DO_FCALL                                      0  $16     
         15        FETCH_DIM_R                                      ~17     $16, 0
         16        ASSIGN                                                   !3, ~17
   15    17        FETCH_OBJ_R                                      ~19     !3, 'classList'
         18        ASSIGN                                                   !4, ~19
   17    19        INIT_METHOD_CALL                                         !4, 'contains'
         20        SEND_VAL_EX                                              'blockImg'
         21        DO_FCALL                                      0  $21     
         22      > JMPZ_EX                                          ~22     $21, ->32
         23    >   INIT_METHOD_CALL                                         !4, 'contains'
         24        SEND_VAL_EX                                              'imgRight'
         25        DO_FCALL                                      0  $23     
         26      > JMPNZ_EX                                         ~24     $23, ->31
         27    >   INIT_METHOD_CALL                                         !4, 'contains'
         28        SEND_VAL_EX                                              'imgLeft'
         29        DO_FCALL                                      0  $25     
         30        BOOL                                             ~24     $25
         31    >   BOOL                                             ~22     ~24
         32    > > JMPZ                                                     ~22, ->57
   18    33    >   INIT_METHOD_CALL                                         !4, 'contains'
         34        SEND_VAL_EX                                              'imgRight'
         35        DO_FCALL                                      0  $26     
         36      > JMPZ                                                     $26, ->39
         37    >   QM_ASSIGN                                        ~27     'imgRight'
         38      > JMP                                                      ->40
         39    >   QM_ASSIGN                                        ~27     'imgLeft'
         40    >   ASSIGN                                                   !5, ~27
   19    41        INIT_METHOD_CALL                                         !2, 'evaluate'
         42        SEND_VAL_EX                                              'string%28img%2F%40src%29'
         43        SEND_VAR_EX                                              !3
         44        DO_FCALL                                      0  $29     
         45        ASSIGN                                                   !6, $29
   20    46        INIT_METHOD_CALL                                         !2, 'evaluate'
         47        SEND_VAL_EX                                              'string%28figcaption%29'
         48        SEND_VAR_EX                                              !3
         49        DO_FCALL                                      0  $31     
         50        ASSIGN                                                   !7, $31
   22    51        ECHO                                                     !5
         52        ECHO                                                     '%0A'
         53        ECHO                                                     !6
         54        ECHO                                                     '%0A'
         55        ECHO                                                     !7
         56        ECHO                                                     '%0A'
   23    57    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.66 ms | 1017 KiB | 13 Q