3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test( $input) { $doc = new DOMDocument; $doc->loadHTML( $input); $p = $doc->getElementsByTagName('p')->item(0); if( strlen( $p->textContent) > 0) { echo 'NOT ok' . "\n"; } else { echo 'OK' . "\n"; } } $input = '<p><img src="#" /></p>'; // ok test( $input); $input = '<p><img src="#" /><img src="#" /></p>'; // ok test( $input); $input = '<p>xxx<img src="#" /></p>'; // ok test( $input); $input = '<p><img src="#" />xxx</p>'; // NOT ok test( $input);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J72A5
function name:  (null)
number of ops:  17
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, '%3Cp%3E%3Cimg+src%3D%22%23%22+%2F%3E%3C%2Fp%3E'
   14     1        INIT_FCALL                                               'test'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
   16     4        ASSIGN                                                   !0, '%3Cp%3E%3Cimg+src%3D%22%23%22+%2F%3E%3Cimg+src%3D%22%23%22+%2F%3E%3C%2Fp%3E'
   17     5        INIT_FCALL                                               'test'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0          
   19     8        ASSIGN                                                   !0, '%3Cp%3Exxx%3Cimg+src%3D%22%23%22+%2F%3E%3C%2Fp%3E'
   20     9        INIT_FCALL                                               'test'
         10        SEND_VAR                                                 !0
         11        DO_FCALL                                      0          
   22    12        ASSIGN                                                   !0, '%3Cp%3E%3Cimg+src%3D%22%23%22+%2F%3Exxx%3C%2Fp%3E'
   23    13        INIT_FCALL                                               'test'
         14        SEND_VAR                                                 !0
         15        DO_FCALL                                      0          
         16      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J72A5
function name:  test
number of ops:  22
compiled vars:  !0 = $input, !1 = $doc, !2 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        NEW                                              $3      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
    4     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
    5     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'p'
          9        DO_FCALL                                      0  $7      
         10        INIT_METHOD_CALL                                         $7, 'item'
         11        SEND_VAL_EX                                              0
         12        DO_FCALL                                      0  $8      
         13        ASSIGN                                                   !2, $8
    6    14        FETCH_OBJ_R                                      ~10     !2, 'textContent'
         15        STRLEN                                           ~11     ~10
         16        IS_SMALLER                                               0, ~11
         17      > JMPZ                                                     ~12, ->20
    7    18    >   ECHO                                                     'NOT+ok%0A'
         19      > JMP                                                      ->21
    9    20    >   ECHO                                                     'OK%0A'
   11    21    > > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.23 ms | 1394 KiB | 17 Q