3v4l.org

run code in 300+ PHP versions simultaneously
<?php function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $data = curl_exec($ch); curl_close($ch); return $data; } $html = file_get_contents_curl("http://google.com/"); //parsing begins here: $doc = new DOMDocument(); @$doc->loadHTML($html); $nodes = $doc->getElementsByTagName('title'); //get and display what you need: $title = $nodes->item(0)->nodeValue; $metas = $doc->getElementsByTagName('meta'); for ($i = 0; $i < $metas->length; $i++) { $meta = $metas->item($i); if($meta->getAttribute('name') == 'description') $description = $meta->getAttribute('content'); if($meta->getAttribute('name') == 'keywords') $keywords = $meta->getAttribute('content'); } echo "Title: $title". '<br/><br/>'; echo "Description: $description". '<br/><br/>'; echo "Keywords: $keywords"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 27
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 40
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 49
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 27
Branch analysis from position: 53
Branch analysis from position: 27
Branch analysis from position: 49
Branch analysis from position: 40
filename:       /in/1CnVp
function name:  (null)
number of ops:  65
compiled vars:  !0 = $html, !1 = $doc, !2 = $nodes, !3 = $title, !4 = $metas, !5 = $i, !6 = $meta, !7 = $description, !8 = $keywords
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'file_get_contents_curl'
          1        SEND_VAL                                                 'http%3A%2F%2Fgoogle.com%2F'
          2        DO_FCALL                                      0  $9      
          3        ASSIGN                                                   !0, $9
   20     4        NEW                                              $11     'DOMDocument'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $11
   21     7        BEGIN_SILENCE                                    ~14     
          8        INIT_METHOD_CALL                                         !1, 'loadHTML'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
         11        END_SILENCE                                              ~14
   22    12        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         13        SEND_VAL_EX                                              'title'
         14        DO_FCALL                                      0  $16     
         15        ASSIGN                                                   !2, $16
   25    16        INIT_METHOD_CALL                                         !2, 'item'
         17        SEND_VAL_EX                                              0
         18        DO_FCALL                                      0  $18     
         19        FETCH_OBJ_R                                      ~19     $18, 'nodeValue'
         20        ASSIGN                                                   !3, ~19
   27    21        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         22        SEND_VAL_EX                                              'meta'
         23        DO_FCALL                                      0  $21     
         24        ASSIGN                                                   !4, $21
   29    25        ASSIGN                                                   !5, 0
         26      > JMP                                                      ->50
   31    27    >   INIT_METHOD_CALL                                         !4, 'item'
         28        SEND_VAR_EX                                              !5
         29        DO_FCALL                                      0  $24     
         30        ASSIGN                                                   !6, $24
   32    31        INIT_METHOD_CALL                                         !6, 'getAttribute'
         32        SEND_VAL_EX                                              'name'
         33        DO_FCALL                                      0  $26     
         34        IS_EQUAL                                                 $26, 'description'
         35      > JMPZ                                                     ~27, ->40
   33    36    >   INIT_METHOD_CALL                                         !6, 'getAttribute'
         37        SEND_VAL_EX                                              'content'
         38        DO_FCALL                                      0  $28     
         39        ASSIGN                                                   !7, $28
   34    40    >   INIT_METHOD_CALL                                         !6, 'getAttribute'
         41        SEND_VAL_EX                                              'name'
         42        DO_FCALL                                      0  $30     
         43        IS_EQUAL                                                 $30, 'keywords'
         44      > JMPZ                                                     ~31, ->49
   35    45    >   INIT_METHOD_CALL                                         !6, 'getAttribute'
         46        SEND_VAL_EX                                              'content'
         47        DO_FCALL                                      0  $32     
         48        ASSIGN                                                   !8, $32
   29    49    >   PRE_INC                                                  !5
         50    >   FETCH_OBJ_R                                      ~35     !4, 'length'
         51        IS_SMALLER                                               !5, ~35
         52      > JMPNZ                                                    ~36, ->27
   38    53    >   NOP                                                      
         54        FAST_CONCAT                                      ~37     'Title%3A+', !3
         55        CONCAT                                           ~38     ~37, '%3Cbr%2F%3E%3Cbr%2F%3E'
         56        ECHO                                                     ~38
   39    57        NOP                                                      
         58        FAST_CONCAT                                      ~39     'Description%3A+', !7
         59        CONCAT                                           ~40     ~39, '%3Cbr%2F%3E%3Cbr%2F%3E'
         60        ECHO                                                     ~40
   40    61        NOP                                                      
         62        FAST_CONCAT                                      ~41     'Keywords%3A+', !8
         63        ECHO                                                     ~41
   41    64      > RETURN                                                   1

Function file_get_contents_curl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1CnVp
function name:  file_get_contents_curl
number of ops:  37
compiled vars:  !0 = $url, !1 = $ch, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL_BY_NAME                                       'curl_init'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
    6     4        INIT_FCALL_BY_NAME                                       'curl_setopt'
          5        SEND_VAR_EX                                              !1
          6        FETCH_CONSTANT                                   ~5      'CURLOPT_HEADER'
          7        SEND_VAL_EX                                              ~5
          8        SEND_VAL_EX                                              0
          9        DO_FCALL                                      0          
    7    10        INIT_FCALL_BY_NAME                                       'curl_setopt'
         11        SEND_VAR_EX                                              !1
         12        FETCH_CONSTANT                                   ~7      'CURLOPT_RETURNTRANSFER'
         13        SEND_VAL_EX                                              ~7
         14        SEND_VAL_EX                                              1
         15        DO_FCALL                                      0          
    8    16        INIT_FCALL_BY_NAME                                       'curl_setopt'
         17        SEND_VAR_EX                                              !1
         18        FETCH_CONSTANT                                   ~9      'CURLOPT_URL'
         19        SEND_VAL_EX                                              ~9
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0          
    9    22        INIT_FCALL_BY_NAME                                       'curl_setopt'
         23        SEND_VAR_EX                                              !1
         24        FETCH_CONSTANT                                   ~11     'CURLOPT_FOLLOWLOCATION'
         25        SEND_VAL_EX                                              ~11
         26        SEND_VAL_EX                                              1
         27        DO_FCALL                                      0          
   11    28        INIT_FCALL_BY_NAME                                       'curl_exec'
         29        SEND_VAR_EX                                              !1
         30        DO_FCALL                                      0  $13     
         31        ASSIGN                                                   !2, $13
   12    32        INIT_FCALL_BY_NAME                                       'curl_close'
         33        SEND_VAR_EX                                              !1
         34        DO_FCALL                                      0          
   14    35      > RETURN                                                   !2
   15    36*     > RETURN                                                   null

End of function file_get_contents_curl

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.31 ms | 1407 KiB | 14 Q