3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_GET['url']='https://www.lostfilm.tv/serials.php'; if(!$_GET['url']) exit; function gethtml($html) { $ch = curl_init(); //open curl handle curl_setopt($ch, CURLOPT_URL, $html); //set an url curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //do not output directly, use variable curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); //do a binary transfer curl_setopt($ch, CURLOPT_FAILONERROR, 1); //stop if an error occurred $file=curl_exec($ch); //store the content in variable if(!curl_errno($ch)) { //header ("Content-type: ".curl_getinfo($ch, CURLINFO_CONTENT_TYPE).""); //header ("Content-Length: ".curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD).""); echo $file; return $file; } else echo 'Curl error: ' . curl_error($ch); curl_close($ch); } $url = $_GET['url']; if(!is_null($_GET['url'])) { $dom = new DOMDocument; @$dom->loadHTML(gethtml($url)); echo json_encode(123); $xpath = new DOMXpath($dom); $links = iterator_to_array($xpath->query('//*[@class="a_discuss"]')); $names = iterator_to_array($xpath->query('//*[@id="new_sd_list"]/span[*]/a/text()')); $array = array(); echo json_encode(123); for($i = 0; $i < count($links) && $i < count($names); ++$i) { $array[0][$i] = mb_convert_encoding($names[$i]->nodue, 'Windows-1251', 'UTF-8'); $array[1][$i] = $links[$i] = str_replace("/discuss.php?cat", "https://www.lostfilm.tv/nrdr2.php?c", $links[$i]->attributes->getNamedItem("href")->nodue); // echo json_encode($array); // echo "<br/>name". $i ."|". mb_convert_encoding($names[$i]->nodue, 'Windows-1251', 'UTF-8'); // echo "<br/>link". $i ."|". $links[$i] = str_replace("/discuss.php?cat", "https://www.lostfilm.tv/nrdr2.php?c", $links[$i]->attributes->getNamedItem("href")->nodue); } echo "var_dump<br />"; echo var_dump($array)."<br /><br />"; echo "print_r<br />"; print_r($array); echo "<br /><br />json_encode<br />"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 101
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 83
Branch analysis from position: 83
2 jumps found. (Code = 46) Position 1 = 86, Position 2 = 89
Branch analysis from position: 86
2 jumps found. (Code = 44) Position 1 = 90, Position 2 = 56
Branch analysis from position: 90
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
2 jumps found. (Code = 46) Position 1 = 86, Position 2 = 89
Branch analysis from position: 86
Branch analysis from position: 89
Branch analysis from position: 89
Branch analysis from position: 101
filename:       /in/qslh7
function name:  (null)
number of ops:  102
compiled vars:  !0 = $url, !1 = $dom, !2 = $xpath, !3 = $links, !4 = $names, !5 = $array, !6 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   FETCH_W                      global              $7      '_GET'
          1        ASSIGN_DIM                                               $7, 'url'
          2        OP_DATA                                                  'https%3A%2F%2Fwww.lostfilm.tv%2Fserials.php'
    3     3        FETCH_R                      global              ~9      '_GET'
          4        FETCH_DIM_R                                      ~10     ~9, 'url'
          5        BOOL_NOT                                         ~11     ~10
          6      > JMPZ                                                     ~11, ->8
          7    > > EXIT                                                     
   20     8    >   FETCH_R                      global              ~12     '_GET'
          9        FETCH_DIM_R                                      ~13     ~12, 'url'
         10        ASSIGN                                                   !0, ~13
   21    11        FETCH_R                      global              ~15     '_GET'
         12        FETCH_DIM_R                                      ~16     ~15, 'url'
         13        TYPE_CHECK                                    2  ~17     ~16
         14        BOOL_NOT                                         ~18     ~17
         15      > JMPZ                                                     ~18, ->101
   22    16    >   NEW                                              $19     'DOMDocument'
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !1, $19
   23    19        BEGIN_SILENCE                                    ~22     
         20        INIT_METHOD_CALL                                         !1, 'loadHTML'
         21        INIT_FCALL                                               'gethtml'
         22        SEND_VAR                                                 !0
         23        DO_FCALL                                      0  $23     
         24        SEND_VAR_NO_REF_EX                                       $23
         25        DO_FCALL                                      0          
         26        END_SILENCE                                              ~22
   24    27        INIT_FCALL                                               'json_encode'
         28        SEND_VAL                                                 123
         29        DO_ICALL                                         $25     
         30        ECHO                                                     $25
   25    31        NEW                                              $26     'DOMXpath'
         32        SEND_VAR_EX                                              !1
         33        DO_FCALL                                      0          
         34        ASSIGN                                                   !2, $26
   26    35        INIT_FCALL                                               'iterator_to_array'
         36        INIT_METHOD_CALL                                         !2, 'query'
         37        SEND_VAL_EX                                              '%2F%2F%2A%5B%40class%3D%22a_discuss%22%5D'
         38        DO_FCALL                                      0  $29     
         39        SEND_VAR                                                 $29
         40        DO_ICALL                                         $30     
         41        ASSIGN                                                   !3, $30
   27    42        INIT_FCALL                                               'iterator_to_array'
         43        INIT_METHOD_CALL                                         !2, 'query'
         44        SEND_VAL_EX                                              '%2F%2F%2A%5B%40id%3D%22new_sd_list%22%5D%2Fspan%5B%2A%5D%2Fa%2Ftext%28%29'
         45        DO_FCALL                                      0  $32     
         46        SEND_VAR                                                 $32
         47        DO_ICALL                                         $33     
         48        ASSIGN                                                   !4, $33
   28    49        ASSIGN                                                   !5, <array>
   29    50        INIT_FCALL                                               'json_encode'
         51        SEND_VAL                                                 123
         52        DO_ICALL                                         $36     
         53        ECHO                                                     $36
   30    54        ASSIGN                                                   !6, 0
         55      > JMP                                                      ->83
   31    56    >   INIT_FCALL                                               'mb_convert_encoding'
         57        FETCH_DIM_R                                      ~40     !4, !6
         58        FETCH_OBJ_R                                      ~41     ~40, 'nodue'
         59        SEND_VAL                                                 ~41
         60        SEND_VAL                                                 'Windows-1251'
         61        SEND_VAL                                                 'UTF-8'
         62        DO_ICALL                                         $42     
         63        FETCH_DIM_W                                      $38     !5, 0
         64        ASSIGN_DIM                                               $38, !6
         65        OP_DATA                                                  $42
   32    66        INIT_FCALL                                               'str_replace'
         67        SEND_VAL                                                 '%2Fdiscuss.php%3Fcat'
         68        SEND_VAL                                                 'https%3A%2F%2Fwww.lostfilm.tv%2Fnrdr2.php%3Fc'
         69        FETCH_DIM_R                                      ~46     !3, !6
         70        FETCH_OBJ_R                                      ~47     ~46, 'attributes'
         71        INIT_METHOD_CALL                                         ~47, 'getNamedItem'
         72        SEND_VAL_EX                                              'href'
         73        DO_FCALL                                      0  $48     
         74        FETCH_OBJ_R                                      ~49     $48, 'nodue'
         75        SEND_VAL                                                 ~49
         76        DO_ICALL                                         $50     
         77        ASSIGN_DIM                                       ~45     !3, !6
         78        OP_DATA                                                  $50
         79        FETCH_DIM_W                                      $43     !5, 1
         80        ASSIGN_DIM                                               $43, !6
         81        OP_DATA                                                  ~45
   30    82        PRE_INC                                                  !6
         83    >   COUNT                                            ~52     !3
         84        IS_SMALLER                                       ~53     !6, ~52
         85      > JMPZ_EX                                          ~53     ~53, ->89
         86    >   COUNT                                            ~54     !4
         87        IS_SMALLER                                       ~55     !6, ~54
         88        BOOL                                             ~53     ~55
         89    > > JMPNZ                                                    ~53, ->56
   37    90    >   ECHO                                                     'var_dump%3Cbr+%2F%3E'
   38    91        INIT_FCALL                                               'var_dump'
         92        SEND_VAR                                                 !5
         93        DO_ICALL                                         $56     
         94        CONCAT                                           ~57     $56, '%3Cbr+%2F%3E%3Cbr+%2F%3E'
         95        ECHO                                                     ~57
   39    96        ECHO                                                     'print_r%3Cbr+%2F%3E'
   40    97        INIT_FCALL                                               'print_r'
         98        SEND_VAR                                                 !5
         99        DO_ICALL                                                 
   41   100        ECHO                                                     '%3Cbr+%2F%3E%3Cbr+%2F%3Ejson_encode%3Cbr+%2F%3E'
   42   101    > > RETURN                                                   1

Function gethtml:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 40
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qslh7
function name:  gethtml
number of ops:  49
compiled vars:  !0 = $html, !1 = $ch, !2 = $file
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     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_URL'
          7        SEND_VAL_EX                                              ~5
          8        SEND_VAR_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_BINARYTRANSFER'
         19        SEND_VAL_EX                                              ~9
         20        SEND_VAL_EX                                              1
         21        DO_FCALL                                      0          
    9    22        INIT_FCALL_BY_NAME                                       'curl_setopt'
         23        SEND_VAR_EX                                              !1
         24        FETCH_CONSTANT                                   ~11     'CURLOPT_FAILONERROR'
         25        SEND_VAL_EX                                              ~11
         26        SEND_VAL_EX                                              1
         27        DO_FCALL                                      0          
   10    28        INIT_FCALL_BY_NAME                                       'curl_exec'
         29        SEND_VAR_EX                                              !1
         30        DO_FCALL                                      0  $13     
         31        ASSIGN                                                   !2, $13
   11    32        INIT_FCALL_BY_NAME                                       'curl_errno'
         33        SEND_VAR_EX                                              !1
         34        DO_FCALL                                      0  $15     
         35        BOOL_NOT                                         ~16     $15
         36      > JMPZ                                                     ~16, ->40
   15    37    >   ECHO                                                     !2
   16    38      > RETURN                                                   !2
         39*       JMP                                                      ->45
   17    40    >   INIT_FCALL_BY_NAME                                       'curl_error'
         41        SEND_VAR_EX                                              !1
         42        DO_FCALL                                      0  $17     
         43        CONCAT                                           ~18     'Curl+error%3A+', $17
         44        ECHO                                                     ~18
   18    45        INIT_FCALL_BY_NAME                                       'curl_close'
         46        SEND_VAR_EX                                              !1
         47        DO_FCALL                                      0          
   19    48      > RETURN                                                   null

End of function gethtml

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.29 ms | 1411 KiB | 26 Q