3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = 'https://secure.i-web.ch/dweb/uri/de/behoerdenmain/gerichtetop/rechtsprechung/?action=info&pubid=4762'; $site = getSiteContent($url); // echo $site; $linksArr = getDomLinks($site); displayArray($linksArr); exit; function getSiteContent($url, $cookieFile = NULL) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0'); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile); $data = curl_exec($ch); curl_close($ch); return $data; } function getDomLinks($contents) { $linkArr = array(); $dom = new domDocument; @$dom->loadHTML($contents); $links = $dom->getElementsByTagName('a'); foreach ($links as $tag) { $linkArr[$tag->getAttribute('href')] = $tag->childNodes->item(0)->nodeValue; } return $linkArr; } function displayArray($aArray) { if (is_array($aArray) && (count($aArray) > 0)) { print("<table border=1>"); print("<tr><th>Key</th><th>Value</th></tr>"); foreach ($aArray as $aKey => $aValue) { print("<tr>"); if (!is_array($aValue)) { if (empty($aValue)) { print("<td>$aKey</td><td><i>$aValue</i></td>"); } else { print("<td>$aKey</td><td>$aValue</td>"); } } else { print("<td>$aKey(array)</td><td>"); displayArray($aValue); print("</td>"); } print("</tr>"); } print("</table>"); } else { print("<i>empty or invalid</i>"); } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/slLXK
function name:  (null)
number of ops:  14
compiled vars:  !0 = $url, !1 = $site, !2 = $linksArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'https%3A%2F%2Fsecure.i-web.ch%2Fdweb%2Furi%2Fde%2Fbehoerdenmain%2Fgerichtetop%2Frechtsprechung%2F%3Faction%3Dinfo%26pubid%3D4762'
    5     1        INIT_FCALL_BY_NAME                                       'getSiteContent'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
    8     5        INIT_FCALL_BY_NAME                                       'getDomLinks'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !2, $6
    9     9        INIT_FCALL_BY_NAME                                       'displayArray'
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0          
   10    12      > EXIT                                                     
   72    13*     > RETURN                                                   1

Function getsitecontent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/slLXK
function name:  getSiteContent
number of ops:  57
compiled vars:  !0 = $url, !1 = $cookieFile, !2 = $ch, !3 = $timeout, !4 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   15     2        INIT_FCALL_BY_NAME                                       'curl_init'
          3        DO_FCALL                                      0  $5      
          4        ASSIGN                                                   !2, $5
   16     5        ASSIGN                                                   !3, 5
   17     6        INIT_FCALL_BY_NAME                                       'curl_setopt'
          7        SEND_VAR_EX                                              !2
          8        FETCH_CONSTANT                                   ~8      'CURLOPT_URL'
          9        SEND_VAL_EX                                              ~8
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
   18    12        INIT_FCALL_BY_NAME                                       'curl_setopt'
         13        SEND_VAR_EX                                              !2
         14        FETCH_CONSTANT                                   ~10     'CURLOPT_USERAGENT'
         15        SEND_VAL_EX                                              ~10
         16        SEND_VAL_EX                                              'Mozilla%2F5.0+%28X11%3B+Ubuntu%3B+Linux+x86_64%3B+rv%3A31.0%29+Gecko%2F20100101+Firefox%2F31.0'
         17        DO_FCALL                                      0          
   19    18        INIT_FCALL_BY_NAME                                       'curl_setopt'
         19        SEND_VAR_EX                                              !2
         20        FETCH_CONSTANT                                   ~12     'CURLOPT_RETURNTRANSFER'
         21        SEND_VAL_EX                                              ~12
         22        SEND_VAL_EX                                              1
         23        DO_FCALL                                      0          
   20    24        INIT_FCALL_BY_NAME                                       'curl_setopt'
         25        SEND_VAR_EX                                              !2
         26        FETCH_CONSTANT                                   ~14     'CURLOPT_CONNECTTIMEOUT'
         27        SEND_VAL_EX                                              ~14
         28        SEND_VAR_EX                                              !3
         29        DO_FCALL                                      0          
   21    30        INIT_FCALL_BY_NAME                                       'curl_setopt'
         31        SEND_VAR_EX                                              !2
         32        FETCH_CONSTANT                                   ~16     'CURLOPT_SSL_VERIFYPEER'
         33        SEND_VAL_EX                                              ~16
         34        SEND_VAL_EX                                              <false>
         35        DO_FCALL                                      0          
   22    36        INIT_FCALL_BY_NAME                                       'curl_setopt'
         37        SEND_VAR_EX                                              !2
         38        FETCH_CONSTANT                                   ~18     'CURLOPT_COOKIEJAR'
         39        SEND_VAL_EX                                              ~18
         40        SEND_VAR_EX                                              !1
         41        DO_FCALL                                      0          
   23    42        INIT_FCALL_BY_NAME                                       'curl_setopt'
         43        SEND_VAR_EX                                              !2
         44        FETCH_CONSTANT                                   ~20     'CURLOPT_COOKIEFILE'
         45        SEND_VAL_EX                                              ~20
         46        SEND_VAR_EX                                              !1
         47        DO_FCALL                                      0          
   24    48        INIT_FCALL_BY_NAME                                       'curl_exec'
         49        SEND_VAR_EX                                              !2
         50        DO_FCALL                                      0  $22     
         51        ASSIGN                                                   !4, $22
   25    52        INIT_FCALL_BY_NAME                                       'curl_close'
         53        SEND_VAR_EX                                              !2
         54        DO_FCALL                                      0          
   26    55      > RETURN                                                   !4
   27    56*     > RETURN                                                   null

End of function getsitecontent

Function getdomlinks:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 27
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 27
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/slLXK
function name:  getDomLinks
number of ops:  30
compiled vars:  !0 = $contents, !1 = $linkArr, !2 = $dom, !3 = $links, !4 = $tag
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   32     1        ASSIGN                                                   !1, <array>
   33     2        NEW                                              $6      'domDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $6
   34     5        BEGIN_SILENCE                                    ~9      
          6        INIT_METHOD_CALL                                         !2, 'loadHTML'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
          9        END_SILENCE                                              ~9
   35    10        INIT_METHOD_CALL                                         !2, 'getElementsByTagName'
         11        SEND_VAL_EX                                              'a'
         12        DO_FCALL                                      0  $11     
         13        ASSIGN                                                   !3, $11
   36    14      > FE_RESET_R                                       $13     !3, ->27
         15    > > FE_FETCH_R                                               $13, !4, ->27
   38    16    >   INIT_METHOD_CALL                                         !4, 'getAttribute'
         17        SEND_VAL_EX                                              'href'
         18        DO_FCALL                                      0  $14     
         19        FETCH_OBJ_R                                      ~16     !4, 'childNodes'
         20        INIT_METHOD_CALL                                         ~16, 'item'
         21        SEND_VAL_EX                                              0
         22        DO_FCALL                                      0  $17     
         23        FETCH_OBJ_R                                      ~18     $17, 'nodeValue'
         24        ASSIGN_DIM                                               !1, $14
         25        OP_DATA                                                  ~18
   36    26      > JMP                                                      ->15
         27    >   FE_FREE                                                  $13
   40    28      > RETURN                                                   !1
   41    29*     > RETURN                                                   null

End of function getdomlinks

Function displayarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 45
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 42
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 42
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 32
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 25
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/slLXK
function name:  displayArray
number of ops:  47
compiled vars:  !0 = $aArray, !1 = $aValue, !2 = $aKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
   47     1        TYPE_CHECK                                  128  ~3      !0
          2      > JMPZ_EX                                          ~3      ~3, ->6
          3    >   COUNT                                            ~4      !0
          4        IS_SMALLER                                       ~5      0, ~4
          5        BOOL                                             ~3      ~5
          6    > > JMPZ                                                     ~3, ->45
   48     7    >   ECHO                                                     '%3Ctable+border%3D1%3E'
   49     8        ECHO                                                     '%3Ctr%3E%3Cth%3EKey%3C%2Fth%3E%3Cth%3EValue%3C%2Fth%3E%3C%2Ftr%3E'
   50     9      > FE_RESET_R                                       $6      !0, ->42
         10    > > FE_FETCH_R                                       ~7      $6, !1, ->42
         11    >   ASSIGN                                                   !2, ~7
   51    12        ECHO                                                     '%3Ctr%3E'
   52    13        TYPE_CHECK                                  128  ~9      !1
         14        BOOL_NOT                                         ~10     ~9
         15      > JMPZ                                                     ~10, ->32
   53    16    >   ISSET_ISEMPTY_CV                                         !1
         17      > JMPZ                                                     ~11, ->25
   54    18    >   ROPE_INIT                                     5  ~13     '%3Ctd%3E'
         19        ROPE_ADD                                      1  ~13     ~13, !2
         20        ROPE_ADD                                      2  ~13     ~13, '%3C%2Ftd%3E%3Ctd%3E%3Ci%3E'
         21        ROPE_ADD                                      3  ~13     ~13, !1
         22        ROPE_END                                      4  ~12     ~13, '%3C%2Fi%3E%3C%2Ftd%3E'
         23        ECHO                                                     ~12
         24      > JMP                                                      ->31
   56    25    >   ROPE_INIT                                     5  ~17     '%3Ctd%3E'
         26        ROPE_ADD                                      1  ~17     ~17, !2
         27        ROPE_ADD                                      2  ~17     ~17, '%3C%2Ftd%3E%3Ctd%3E'
         28        ROPE_ADD                                      3  ~17     ~17, !1
         29        ROPE_END                                      4  ~16     ~17, '%3C%2Ftd%3E'
         30        ECHO                                                     ~16
         31    > > JMP                                                      ->40
   59    32    >   ROPE_INIT                                     3  ~21     '%3Ctd%3E'
         33        ROPE_ADD                                      1  ~21     ~21, !2
         34        ROPE_END                                      2  ~20     ~21, '%28array%29%3C%2Ftd%3E%3Ctd%3E'
         35        ECHO                                                     ~20
   60    36        INIT_FCALL_BY_NAME                                       'displayArray'
         37        SEND_VAR_EX                                              !1
         38        DO_FCALL                                      0          
   61    39        ECHO                                                     '%3C%2Ftd%3E'
   63    40    >   ECHO                                                     '%3C%2Ftr%3E'
   50    41      > JMP                                                      ->10
         42    >   FE_FREE                                                  $6
   65    43        ECHO                                                     '%3C%2Ftable%3E'
         44      > JMP                                                      ->46
   67    45    >   ECHO                                                     '%3Ci%3Eempty+or+invalid%3C%2Fi%3E'
   69    46    > > RETURN                                                   null

End of function displayarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.94 ms | 1407 KiB | 13 Q