3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test( $input) { $doc = new DOMDocument; $doc->loadHTML( $input); $p = $doc->getElementsByTagName('a'); print_r($p); //->item(0); /*$children = $p->childNodes; $img_found = false; $error = false; foreach( $children as $child) { if( $child->nodeType == XML_TEXT_NODE && !$img_found) { // Text before the image, OK, continue on continue; } if( $child->nodeType == XML_ELEMENT_NODE) { if( !($child->tagName == 'img')) { // echo "Invalid HTML element found"; $error = true; } else { $img_found = true; } } else { // echo "Invalid node type!"; $error = true; } } if( $img_found && !$error) { echo 'ok' . "\n"; } else { echo 'NOT ok' . "\n"; }*/ } $input = addslashes('<a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/Interschool-championship.gif"><a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0889.jpg"><img class="aligncenter size-full wp-image-1928" alt="sports championship competition" src="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0889.jpg" width="1024" height="768" /></a><a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0830.jpg"><img class="aligncenter size-full wp-image-1929" alt="sports championship competition" src="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0830.jpg" width="1024" height="768" /></a></a>'); // ok test( $input);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EVM2j
function name:  (null)
number of ops:  8
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL                                               'addslashes'
          1        SEND_VAL                                                 '%3Ca+href%3D%22http%3A%2F%2Finorbit.in%2Fwhitefield%2Fwp-content%2Fuploads%2Fsites%2F4%2F2014%2F06%2FInterschool-championship.gif%22%3E%3Ca+href%3D%22http%3A%2F%2Finorbit.in%2Fwhitefield%2Fwp-content%2Fuploads%2Fsites%2F4%2F2014%2F06%2FIMG_0889.jpg%22%3E%3Cimg+class%3D%22aligncenter+size-full+wp-image-1928%22+alt%3D%22sports+championship+competition%22+src%3D%22http%3A%2F%2Finorbit.in%2Fwhitefield%2Fwp-content%2Fuploads%2Fsites%2F4%2F2014%2F06%2FIMG_0889.jpg%22+width%3D%221024%22+height%3D%22768%22+%2F%3E%3C%2Fa%3E%3Ca+href%3D%22http%3A%2F%2Finorbit.in%2Fwhitefield%2Fwp-content%2Fuploads%2Fsites%2F4%2F2014%2F06%2FIMG_0830.jpg%22%3E%3Cimg+class%3D%22aligncenter+size-full+wp-image-1929%22+alt%3D%22sports+championship+competition%22+src%3D%22http%3A%2F%2Finorbit.in%2Fwhitefield%2Fwp-content%2Fuploads%2Fsites%2F4%2F2014%2F06%2FIMG_0830.jpg%22+width%3D%221024%22+height%3D%22768%22+%2F%3E%3C%2Fa%3E%3C%2Fa%3E'
          2        DO_ICALL                                         $1      
          3        ASSIGN                                                   !0, $1
   35     4        INIT_FCALL                                               'test'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EVM2j
function name:  test
number of ops:  15
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                                              'a'
          9        DO_FCALL                                      0  $7      
         10        ASSIGN                                                   !2, $7
    6    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                                 
   32    14      > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.19 ms | 1399 KiB | 18 Q