3v4l.org

run code in 300+ PHP versions simultaneously
<?php // test URLs $urls = array( "http://www.cnn.com", "http://www.mozilla.com", "http://www.facebook.com" ); // test browsers $browsers = array( "standard" => array ( "user_agent" => "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 (.NET CLR 3.5.30729)", "language" => "en-us,en;q=0.5" ), "iphone" => array ( "user_agent" => "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A537a Safari/419.3", "language" => "en" ), "french" => array ( "user_agent" => "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB6; .NET CLR 2.0.50727)", "language" => "fr,fr-FR;q=0.5" ) ); foreach ($urls as $url) { echo "URL: $url\n"; foreach ($browsers as $test_name => $browser) { $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $url); // set browser specific headers curl_setopt($ch, CURLOPT_HTTPHEADER, array( "User-Agent: {$browser['user_agent']}", "Accept-Language: {$browser['language']}" )); // we don't want the page contents curl_setopt($ch, CURLOPT_NOBODY, 1); // we need the HTTP Header returned curl_setopt($ch, CURLOPT_HEADER, 1); // return the results instead of outputting it curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); // was there a redirection HTTP header? if (preg_match("!Location: (.*)!", $output, $matches)) { echo "$test_name: redirects to $matches[1]\n"; } else { echo "$test_name: no redirection\n"; } } echo "\n\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 79
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 79
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 76
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 76
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 72
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 76
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 76
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 79
filename:       /in/BOegK
function name:  (null)
number of ops:  81
compiled vars:  !0 = $urls, !1 = $browsers, !2 = $url, !3 = $browser, !4 = $test_name, !5 = $ch, !6 = $output, !7 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   29     2      > FE_RESET_R                                       $10     !0, ->79
          3    > > FE_FETCH_R                                               $10, !2, ->79
   31     4    >   ROPE_INIT                                     3  ~12     'URL%3A+'
          5        ROPE_ADD                                      1  ~12     ~12, !2
          6        ROPE_END                                      2  ~11     ~12, '%0A'
          7        ECHO                                                     ~11
   33     8      > FE_RESET_R                                       $14     !1, ->76
          9    > > FE_FETCH_R                                       ~15     $14, !3, ->76
         10    >   ASSIGN                                                   !4, ~15
   35    11        INIT_FCALL_BY_NAME                                       'curl_init'
         12        DO_FCALL                                      0  $17     
         13        ASSIGN                                                   !5, $17
   38    14        INIT_FCALL_BY_NAME                                       'curl_setopt'
         15        SEND_VAR_EX                                              !5
         16        FETCH_CONSTANT                                   ~19     'CURLOPT_URL'
         17        SEND_VAL_EX                                              ~19
         18        SEND_VAR_EX                                              !2
         19        DO_FCALL                                      0          
   41    20        INIT_FCALL_BY_NAME                                       'curl_setopt'
         21        SEND_VAR_EX                                              !5
         22        FETCH_CONSTANT                                   ~21     'CURLOPT_HTTPHEADER'
         23        SEND_VAL_EX                                              ~21
   42    24        NOP                                                      
         25        FETCH_DIM_R                                      ~22     !3, 'user_agent'
         26        FAST_CONCAT                                      ~23     'User-Agent%3A+', ~22
         27        INIT_ARRAY                                       ~24     ~23
   43    28        NOP                                                      
         29        FETCH_DIM_R                                      ~25     !3, 'language'
         30        FAST_CONCAT                                      ~26     'Accept-Language%3A+', ~25
         31        ADD_ARRAY_ELEMENT                                ~24     ~26
         32        SEND_VAL_EX                                              ~24
         33        DO_FCALL                                      0          
   47    34        INIT_FCALL_BY_NAME                                       'curl_setopt'
         35        SEND_VAR_EX                                              !5
         36        FETCH_CONSTANT                                   ~28     'CURLOPT_NOBODY'
         37        SEND_VAL_EX                                              ~28
         38        SEND_VAL_EX                                              1
         39        DO_FCALL                                      0          
   50    40        INIT_FCALL_BY_NAME                                       'curl_setopt'
         41        SEND_VAR_EX                                              !5
         42        FETCH_CONSTANT                                   ~30     'CURLOPT_HEADER'
         43        SEND_VAL_EX                                              ~30
         44        SEND_VAL_EX                                              1
         45        DO_FCALL                                      0          
   53    46        INIT_FCALL_BY_NAME                                       'curl_setopt'
         47        SEND_VAR_EX                                              !5
         48        FETCH_CONSTANT                                   ~32     'CURLOPT_RETURNTRANSFER'
         49        SEND_VAL_EX                                              ~32
         50        SEND_VAL_EX                                              1
         51        DO_FCALL                                      0          
   55    52        INIT_FCALL_BY_NAME                                       'curl_exec'
         53        SEND_VAR_EX                                              !5
         54        DO_FCALL                                      0  $34     
         55        ASSIGN                                                   !6, $34
   57    56        INIT_FCALL_BY_NAME                                       'curl_close'
         57        SEND_VAR_EX                                              !5
         58        DO_FCALL                                      0          
   60    59        INIT_FCALL                                               'preg_match'
         60        SEND_VAL                                                 '%21Location%3A+%28.%2A%29%21'
         61        SEND_VAR                                                 !6
         62        SEND_REF                                                 !7
         63        DO_ICALL                                         $37     
         64      > JMPZ                                                     $37, ->72
   62    65    >   ROPE_INIT                                     4  ~40     !4
         66        ROPE_ADD                                      1  ~40     ~40, '%3A+redirects+to+'
         67        FETCH_DIM_R                                      ~38     !7, 1
         68        ROPE_ADD                                      2  ~40     ~40, ~38
         69        ROPE_END                                      3  ~39     ~40, '%0A'
         70        ECHO                                                     ~39
         71      > JMP                                                      ->75
   66    72    >   NOP                                                      
         73        FAST_CONCAT                                      ~42     !4, '%3A+no+redirection%0A'
         74        ECHO                                                     ~42
   33    75    > > JMP                                                      ->9
         76    >   FE_FREE                                                  $14
   71    77        ECHO                                                     '%0A%0A'
   29    78      > JMP                                                      ->3
         79    >   FE_FREE                                                  $10
   72    80      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.73 ms | 1404 KiB | 15 Q