3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getbody($url) { $dom = new DOMDocument; //$dom->loadHTML($file); $dom->loadHTMLFile($url); $bodies = $dom->getElementsByTagName('body'); assert($bodies->length === 1); $body = $bodies->item(0); for ($i = 0; $i < $body->children->length; $i++) { $body->remove($body->children->item($i)); } $stringbody = $dom->saveHTML($body); return $stringbody; } //$url = "http://stackoverflow.com"; $url = "http://www.barcelona.com"; $body = getbody($url); //var_dump($body); ?> <html> <head></head> <body> <?php echo "BODY ripped from: ".$url."<br/>"; echo "<textarea rows='40' cols='200' >".$body."</textarea>"; ?> </body> </html>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ucrc9
function name:  (null)
number of ops:  14
compiled vars:  !0 = $url, !1 = $body
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fwww.barcelona.com'
   17     1        INIT_FCALL                                               'getbody'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   21     5        ECHO                                                     '%3Chtml%3E%0A%3Chead%3E%3C%2Fhead%3E%0A%3Cbody%3E%0A'
   25     6        CONCAT                                           ~5      'BODY+ripped+from%3A+', !0
          7        CONCAT                                           ~6      ~5, '%3Cbr%2F%3E'
          8        ECHO                                                     ~6
   26     9        CONCAT                                           ~7      '%3Ctextarea+rows%3D%2740%27+cols%3D%27200%27+%3E', !1
         10        CONCAT                                           ~8      ~7, '%3C%2Ftextarea%3E'
         11        ECHO                                                     ~8
   28    12        ECHO                                                     '%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   29    13      > RETURN                                                   1

Function getbody:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 24
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 24
Branch analysis from position: 36
Branch analysis from position: 24
filename:       /in/Ucrc9
function name:  getbody
number of ops:  42
compiled vars:  !0 = $url, !1 = $dom, !2 = $bodies, !3 = $body, !4 = $i, !5 = $stringbody
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
    5     4        INIT_METHOD_CALL                                         !1, 'loadHTMLFile'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
    6     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'body'
          9        DO_FCALL                                      0  $10     
         10        ASSIGN                                                   !2, $10
    7    11        ASSERT_CHECK                                             
         12        INIT_FCALL                                               'assert'
         13        FETCH_OBJ_R                                      ~12     !2, 'length'
         14        IS_IDENTICAL                                     ~13     ~12, 1
         15        SEND_VAL                                                 ~13
         16        SEND_VAL                                                 'assert%28%24bodies-%3Elength+%3D%3D%3D+1%29'
         17        DO_ICALL                                                 
    8    18        INIT_METHOD_CALL                                         !2, 'item'
         19        SEND_VAL_EX                                              0
         20        DO_FCALL                                      0  $15     
         21        ASSIGN                                                   !3, $15
    9    22        ASSIGN                                                   !4, 0
         23      > JMP                                                      ->32
   10    24    >   INIT_METHOD_CALL                                         !3, 'remove'
         25        FETCH_OBJ_R                                      ~18     !3, 'children'
         26        INIT_METHOD_CALL                                         ~18, 'item'
         27        SEND_VAR_EX                                              !4
         28        DO_FCALL                                      0  $19     
         29        SEND_VAR_NO_REF_EX                                       $19
         30        DO_FCALL                                      0          
    9    31        PRE_INC                                                  !4
         32    >   FETCH_OBJ_R                                      ~22     !3, 'children'
         33        FETCH_OBJ_R                                      ~23     ~22, 'length'
         34        IS_SMALLER                                               !4, ~23
         35      > JMPNZ                                                    ~24, ->24
   12    36    >   INIT_METHOD_CALL                                         !1, 'saveHTML'
         37        SEND_VAR_EX                                              !3
         38        DO_FCALL                                      0  $25     
         39        ASSIGN                                                   !5, $25
   13    40      > RETURN                                                   !5
   14    41*     > RETURN                                                   null

End of function getbody

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.23 ms | 1403 KiB | 16 Q