3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lien = "http://www.hatshowroom.com/chapeaux/8-feutre-monkey-noir-3000008353259.html"; if(urlExist($lien) === FALSE){ echo 'KO'; } else { echo "Good"; } function urlExist($url) { $url = @parse_url($url); if (!$url) return false; $url = array_map('trim', $url); $url['port'] = (!isset($url['port'])) ? 80 : (int)$url['port']; $path = (isset($url['path'])) ? $url['path'] : '/'; $path .= (isset($url['query'])) ? "?$url[query]" : ''; if (isset($url['host']) && $url['host'] != gethostbyname($url['host'])) { $fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30); if (!$fp) return false; //socket not opened fputs($fp, "HEAD $path HTTP/1.1rnHost: $url[host]rnrn"); //socket opened $headers = fread($fp, 4096); fclose($fp); if(preg_match('#^HTTP/.*s+[(200|301|302)]+s#i', $headers)){//matching header return true; } else return false; } // if parse url else return false; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OYQK9
function name:  (null)
number of ops:  10
compiled vars:  !0 = $lien
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fwww.hatshowroom.com%2Fchapeaux%2F8-feutre-monkey-noir-3000008353259.html'
    5     1        INIT_FCALL_BY_NAME                                       'urlExist'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        TYPE_CHECK                                    4          $2
          5      > JMPZ                                                     ~3, ->8
    6     6    >   ECHO                                                     'KO'
          7      > JMP                                                      ->9
    8     8    >   ECHO                                                     'Good'
   38     9    > > RETURN                                                   1

Function urlexist:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 39
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 46) Position 1 = 43, Position 2 = 50
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 91
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 64
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 87, Position 2 = 89
Branch analysis from position: 87
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 89
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 91
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
Branch analysis from position: 39
2 jumps found. (Code = 46) Position 1 = 43, Position 2 = 50
Branch analysis from position: 43
Branch analysis from position: 50
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 39
Branch analysis from position: 34
Branch analysis from position: 39
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
Branch analysis from position: 30
filename:       /in/OYQK9
function name:  urlExist
number of ops:  93
compiled vars:  !0 = $url, !1 = $path, !2 = $fp, !3 = $errno, !4 = $errstr, !5 = $headers
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        BEGIN_SILENCE                                    ~6      
          2        INIT_FCALL                                               'parse_url'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        END_SILENCE                                              ~6
          6        ASSIGN                                                   !0, $7
   13     7        BOOL_NOT                                         ~9      !0
          8      > JMPZ                                                     ~9, ->10
          9    > > RETURN                                                   <false>
   15    10    >   INIT_FCALL                                               'array_map'
         11        SEND_VAL                                                 'trim'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !0, $10
   16    15        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !0, 'port'
         16        BOOL_NOT                                         ~14     ~13
         17      > JMPZ                                                     ~14, ->20
         18    >   QM_ASSIGN                                        ~15     80
         19      > JMP                                                      ->23
         20    >   FETCH_DIM_R                                      ~16     !0, 'port'
         21        CAST                                          4  ~17     ~16
         22        QM_ASSIGN                                        ~15     ~17
         23    >   ASSIGN_DIM                                               !0, 'port'
         24        OP_DATA                                                  ~15
   18    25        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'path'
         26      > JMPZ                                                     ~18, ->30
         27    >   FETCH_DIM_R                                      ~19     !0, 'path'
         28        QM_ASSIGN                                        ~20     ~19
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~20     '%2F'
         31    >   ASSIGN                                                   !1, ~20
   19    32        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'query'
         33      > JMPZ                                                     ~22, ->39
         34    >   NOP                                                      
         35        FETCH_DIM_R                                      ~23     !0, 'query'
         36        FAST_CONCAT                                      ~24     '%3F', ~23
         37        QM_ASSIGN                                        ~25     ~24
         38      > JMP                                                      ->40
         39    >   QM_ASSIGN                                        ~25     ''
         40    >   ASSIGN_OP                                     8          !1, ~25
   21    41        ISSET_ISEMPTY_DIM_OBJ                         0  ~27     !0, 'host'
         42      > JMPZ_EX                                          ~27     ~27, ->50
         43    >   FETCH_DIM_R                                      ~28     !0, 'host'
         44        INIT_FCALL                                               'gethostbyname'
         45        FETCH_DIM_R                                      ~29     !0, 'host'
         46        SEND_VAL                                                 ~29
         47        DO_ICALL                                         $30     
         48        IS_NOT_EQUAL                                     ~31     $30, ~28
         49        BOOL                                             ~27     ~31
         50    > > JMPZ                                                     ~27, ->91
   23    51    >   INIT_FCALL                                               'fsockopen'
         52        FETCH_DIM_R                                      ~32     !0, 'host'
         53        SEND_VAL                                                 ~32
         54        FETCH_DIM_R                                      ~33     !0, 'port'
         55        SEND_VAL                                                 ~33
         56        SEND_REF                                                 !3
         57        SEND_REF                                                 !4
         58        SEND_VAL                                                 30
         59        DO_ICALL                                         $34     
         60        ASSIGN                                                   !2, $34
   25    61        BOOL_NOT                                         ~36     !2
         62      > JMPZ                                                     ~36, ->64
         63    > > RETURN                                                   <false>
   27    64    >   INIT_FCALL                                               'fputs'
         65        SEND_VAR                                                 !2
         66        ROPE_INIT                                     5  ~39     'HEAD+'
         67        ROPE_ADD                                      1  ~39     ~39, !1
         68        ROPE_ADD                                      2  ~39     ~39, '+HTTP%2F1.1rnHost%3A+'
         69        FETCH_DIM_R                                      ~37     !0, 'host'
         70        ROPE_ADD                                      3  ~39     ~39, ~37
         71        ROPE_END                                      4  ~38     ~39, 'rnrn'
         72        SEND_VAL                                                 ~38
         73        DO_ICALL                                                 
   28    74        INIT_FCALL                                               'fread'
         75        SEND_VAR                                                 !2
         76        SEND_VAL                                                 4096
         77        DO_ICALL                                         $43     
         78        ASSIGN                                                   !5, $43
   29    79        INIT_FCALL                                               'fclose'
         80        SEND_VAR                                                 !2
         81        DO_ICALL                                                 
   31    82        INIT_FCALL                                               'preg_match'
         83        SEND_VAL                                                 '%23%5EHTTP%2F.%2As%2B%5B%28200%7C301%7C302%29%5D%2Bs%23i'
         84        SEND_VAR                                                 !5
         85        DO_ICALL                                         $46     
         86      > JMPZ                                                     $46, ->89
   32    87    > > RETURN                                                   <true>
         88*       JMP                                                      ->90
   34    89    > > RETURN                                                   <false>
         90*       JMP                                                      ->92
   37    91    > > RETURN                                                   <false>
   38    92*     > RETURN                                                   null

End of function urlexist

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.86 ms | 1404 KiB | 29 Q