3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isAlive($services) { foreach ($services as $address => $port) { $service = array( "address" => $address, "port" => $port, "errno" => "", "errstr" => "", "alive" => false ); $sock = @fsockopen($address, $port, $service["errno"], $service["errstr"], 5); if ($sock) { fprintf($sock, "GET / HTTP/1.0\r\n"); fprintf($sock, "\r\n"); $service["response"] = stream_get_contents($sock); if ($service["response"]) { $service["alive"] = true; } fclose($sock); } yield $service; } } $services = array( "castel.be" => 80, "wardkennes.be" => 80, "lyrecomovies.com" => 80 ); foreach (isAlive($services) as $service) { if (!$service["alive"]) { printf( "%s:%d: failure (%d) %s\n", $service["address"], $service["port"], $service["errno"], $service["errstr"]); } else { printf( "%s:%d: alive: %d bytes\n", $service["address"], $service["port"], strlen($service["response"])); } } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 32
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 32
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 21
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/3HqSr
function name:  (null)
number of ops:  34
compiled vars:  !0 = $services, !1 = $service
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ASSIGN                                                   !0, <array>
   33     1        INIT_FCALL                                               'isalive'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4      > FE_RESET_R                                       $4      $3, ->32
          5    > > FE_FETCH_R                                               $4, !1, ->32
   34     6    >   FETCH_DIM_R                                      ~5      !1, 'alive'
          7        BOOL_NOT                                         ~6      ~5
          8      > JMPZ                                                     ~6, ->21
   35     9    >   INIT_FCALL                                               'printf'
   36    10        SEND_VAL                                                 '%25s%3A%25d%3A+failure+%28%25d%29+%25s%0A'
   37    11        FETCH_DIM_R                                      ~7      !1, 'address'
         12        SEND_VAL                                                 ~7
         13        FETCH_DIM_R                                      ~8      !1, 'port'
         14        SEND_VAL                                                 ~8
         15        FETCH_DIM_R                                      ~9      !1, 'errno'
         16        SEND_VAL                                                 ~9
         17        FETCH_DIM_R                                      ~10     !1, 'errstr'
         18        SEND_VAL                                                 ~10
         19        DO_ICALL                                                 
         20      > JMP                                                      ->31
   39    21    >   INIT_FCALL                                               'printf'
   40    22        SEND_VAL                                                 '%25s%3A%25d%3A+alive%3A+%25d+bytes%0A'
   41    23        FETCH_DIM_R                                      ~12     !1, 'address'
         24        SEND_VAL                                                 ~12
         25        FETCH_DIM_R                                      ~13     !1, 'port'
         26        SEND_VAL                                                 ~13
         27        FETCH_DIM_R                                      ~14     !1, 'response'
         28        STRLEN                                           ~15     ~14
         29        SEND_VAL                                                 ~15
         30        DO_ICALL                                                 
   33    31    > > JMP                                                      ->5
         32    >   FE_FREE                                                  $4
   44    33      > RETURN                                                   1

Function isalive:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 46
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 46
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 44
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 41
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 41
Branch analysis from position: 44
Branch analysis from position: 46
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 46
filename:       /in/3HqSr
function name:  isAlive
number of ops:  48
compiled vars:  !0 = $services, !1 = $port, !2 = $address, !3 = $service, !4 = $sock
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    3     2      > FE_RESET_R                                       $5      !0, ->46
          3    > > FE_FETCH_R                                       ~6      $5, !1, ->46
          4    >   ASSIGN                                                   !2, ~6
    6     5        INIT_ARRAY                                       ~8      !2, 'address'
    7     6        ADD_ARRAY_ELEMENT                                ~8      !1, 'port'
    8     7        ADD_ARRAY_ELEMENT                                ~8      '', 'errno'
    9     8        ADD_ARRAY_ELEMENT                                ~8      '', 'errstr'
    6     9        ADD_ARRAY_ELEMENT                                ~8      <false>, 'alive'
    5    10        ASSIGN                                                   !3, ~8
   13    11        BEGIN_SILENCE                                    ~10     
         12        INIT_FCALL                                               'fsockopen'
         13        SEND_VAR                                                 !2
         14        SEND_VAR                                                 !1
         15        FETCH_DIM_W                                      $11     !3, 'errno'
         16        SEND_REF                                                 $11
         17        FETCH_DIM_W                                      $12     !3, 'errstr'
         18        SEND_REF                                                 $12
         19        SEND_VAL                                                 5
         20        DO_ICALL                                         $13     
         21        END_SILENCE                                              ~10
         22        ASSIGN                                                   !4, $13
   14    23      > JMPZ                                                     !4, ->44
   15    24    >   INIT_FCALL                                               'fprintf'
         25        SEND_VAR                                                 !4
         26        SEND_VAL                                                 'GET+%2F+HTTP%2F1.0%0D%0A'
         27        DO_ICALL                                                 
   16    28        INIT_FCALL                                               'fprintf'
         29        SEND_VAR                                                 !4
         30        SEND_VAL                                                 '%0D%0A'
         31        DO_ICALL                                                 
   17    32        INIT_FCALL                                               'stream_get_contents'
         33        SEND_VAR                                                 !4
         34        DO_ICALL                                         $18     
         35        ASSIGN_DIM                                               !3, 'response'
         36        OP_DATA                                                  $18
   18    37        FETCH_DIM_R                                      ~19     !3, 'response'
         38      > JMPZ                                                     ~19, ->41
   19    39    >   ASSIGN_DIM                                               !3, 'alive'
         40        OP_DATA                                                  <true>
   21    41    >   INIT_FCALL                                               'fclose'
         42        SEND_VAR                                                 !4
         43        DO_ICALL                                                 
   23    44    >   YIELD                                                    !3
    3    45      > JMP                                                      ->3
         46    >   FE_FREE                                                  $5
   25    47      > GENERATOR_RETURN                                         

End of function isalive

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.6 ms | 1407 KiB | 24 Q