3v4l.org

run code in 300+ PHP versions simultaneously
<?php function curlFunc($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $result = curl_exec($ch); curl_close($ch); return $result; } function getYandexNews($q){ $q = str_replace(" ","+",$q); $h = curlFunc('http://news.yandex.ru/yandsearch?text='.$q.'&rpt=nnews2'); preg_match_all('/<a onclick="(.*?)" href="(.*?)"(.*?)class="title">(.*?)<\/a>(.*?)<span class="info">(.*?)<p>(.*?)<\/p>/is', $h, $matches); $SStr = ''; for($i=1;$i<sizeof($matches[1]);$i++){ if(!empty($matches[2][$i])){ $SStr .= '<li><a href="'.trim(strip_tags($matches[2][$i])).'" target="_blank">'.trim(strip_tags($matches[4][$i])).'</a><br /> '.$matches[7][$i].' <small>'.$lm.'</small> </li>'; } } return $SStr; } echo getYandexNews('Zapros');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P5pvR
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   INIT_FCALL                                               'getyandexnews'
          1        SEND_VAL                                                 'Zapros'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function curlfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P5pvR
function name:  curlFunc
number of ops:  49
compiled vars:  !0 = $url, !1 = $ch, !2 = $result
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_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_URL'
         13        SEND_VAL_EX                                              ~7
         14        SEND_VAR_EX                                              !0
         15        DO_FCALL                                      0          
    8    16        INIT_FCALL_BY_NAME                                       'curl_setopt'
         17        SEND_VAR_EX                                              !1
         18        FETCH_CONSTANT                                   ~9      'CURLOPT_TIMEOUT'
         19        SEND_VAL_EX                                              ~9
         20        SEND_VAL_EX                                              10
         21        DO_FCALL                                      0          
    9    22        INIT_FCALL_BY_NAME                                       'curl_setopt'
         23        SEND_VAR_EX                                              !1
         24        FETCH_CONSTANT                                   ~11     'CURLOPT_USERAGENT'
         25        SEND_VAL_EX                                              ~11
         26        SEND_VAL_EX                                              'Mozilla%2F4.0+%28compatible%3B+MSIE+6.0%3B+Windows+NT+5.1%3B+SV1%3B+.NET+CLR+2.0.50727%29'
         27        DO_FCALL                                      0          
   10    28        INIT_FCALL_BY_NAME                                       'curl_setopt'
         29        SEND_VAR_EX                                              !1
         30        FETCH_CONSTANT                                   ~13     'CURLOPT_RETURNTRANSFER'
         31        SEND_VAL_EX                                              ~13
         32        SEND_VAL_EX                                              1
         33        DO_FCALL                                      0          
   11    34        INIT_FCALL_BY_NAME                                       'curl_setopt'
         35        SEND_VAR_EX                                              !1
         36        FETCH_CONSTANT                                   ~15     'CURLOPT_FOLLOWLOCATION'
         37        SEND_VAL_EX                                              ~15
         38        SEND_VAL_EX                                              1
         39        DO_FCALL                                      0          
   12    40        INIT_FCALL_BY_NAME                                       'curl_exec'
         41        SEND_VAR_EX                                              !1
         42        DO_FCALL                                      0  $17     
         43        ASSIGN                                                   !2, $17
   13    44        INIT_FCALL_BY_NAME                                       'curl_close'
         45        SEND_VAR_EX                                              !1
         46        DO_FCALL                                      0          
   14    47      > RETURN                                                   !2
   15    48*     > RETURN                                                   null

End of function curlfunc

Function getyandexnews:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 21
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 52
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 21
Branch analysis from position: 57
Branch analysis from position: 21
Branch analysis from position: 52
filename:       /in/P5pvR
function name:  getYandexNews
number of ops:  59
compiled vars:  !0 = $q, !1 = $h, !2 = $matches, !3 = $SStr, !4 = $i, !5 = $lm
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '+'
          3        SEND_VAL                                                 '%2B'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !0, $6
   21     7        INIT_FCALL                                               'curlfunc'
          8        CONCAT                                           ~8      'http%3A%2F%2Fnews.yandex.ru%2Fyandsearch%3Ftext%3D', !0
          9        CONCAT                                           ~9      ~8, '%26rpt%3Dnnews2'
         10        SEND_VAL                                                 ~9
         11        DO_FCALL                                      0  $10     
         12        ASSIGN                                                   !1, $10
   23    13        INIT_FCALL                                               'preg_match_all'
         14        SEND_VAL                                                 '%2F%3Ca+onclick%3D%22%28.%2A%3F%29%22+href%3D%22%28.%2A%3F%29%22%28.%2A%3F%29class%3D%22title%22%3E%28.%2A%3F%29%3C%5C%2Fa%3E%28.%2A%3F%29%3Cspan+class%3D%22info%22%3E%28.%2A%3F%29%3Cp%3E%28.%2A%3F%29%3C%5C%2Fp%3E%2Fis'
         15        SEND_VAR                                                 !1
         16        SEND_REF                                                 !2
         17        DO_ICALL                                                 
   25    18        ASSIGN                                                   !3, ''
   26    19        ASSIGN                                                   !4, 1
         20      > JMP                                                      ->53
   28    21    >   FETCH_DIM_IS                                     ~15     !2, 2
         22        ISSET_ISEMPTY_DIM_OBJ                         1  ~16     ~15, !4
         23        BOOL_NOT                                         ~17     ~16
         24      > JMPZ                                                     ~17, ->52
   29    25    >   INIT_FCALL                                               'trim'
         26        INIT_FCALL                                               'strip_tags'
         27        FETCH_DIM_R                                      ~18     !2, 2
         28        FETCH_DIM_R                                      ~19     ~18, !4
         29        SEND_VAL                                                 ~19
         30        DO_ICALL                                         $20     
         31        SEND_VAR                                                 $20
         32        DO_ICALL                                         $21     
         33        CONCAT                                           ~22     '%3Cli%3E%3Ca+href%3D%22', $21
         34        CONCAT                                           ~23     ~22, '%22+target%3D%22_blank%22%3E'
         35        INIT_FCALL                                               'trim'
         36        INIT_FCALL                                               'strip_tags'
         37        FETCH_DIM_R                                      ~24     !2, 4
         38        FETCH_DIM_R                                      ~25     ~24, !4
         39        SEND_VAL                                                 ~25
         40        DO_ICALL                                         $26     
         41        SEND_VAR                                                 $26
         42        DO_ICALL                                         $27     
         43        CONCAT                                           ~28     ~23, $27
         44        CONCAT                                           ~29     ~28, '%3C%2Fa%3E%3Cbr+%2F%3E%0A%09++++++++'
   30    45        FETCH_DIM_R                                      ~30     !2, 7
         46        FETCH_DIM_R                                      ~31     ~30, !4
         47        CONCAT                                           ~32     ~29, ~31
         48        CONCAT                                           ~33     ~32, '%0A%09++++++++%3Csmall%3E'
   31    49        CONCAT                                           ~34     ~33, !5
         50        CONCAT                                           ~35     ~34, '%3C%2Fsmall%3E%0A%09++++++++%3C%2Fli%3E'
         51        ASSIGN_OP                                     8          !3, ~35
   26    52    >   PRE_INC                                                  !4
         53    >   FETCH_DIM_R                                      ~38     !2, 1
         54        COUNT                                            ~39     ~38
         55        IS_SMALLER                                               !4, ~39
         56      > JMPNZ                                                    ~40, ->21
   35    57    > > RETURN                                                   !3
   37    58*     > RETURN                                                   null

End of function getyandexnews

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.6 ms | 1407 KiB | 23 Q