3v4l.org

run code in 300+ PHP versions simultaneously
<?php require 'server.inc'; function do_test($version, $connection) { $options = array( 'http' => array( 'protocol_version' => $version, ) ); if ($connection) { $options['http']['header'] = "Connection: $connection"; } $ctx = stream_context_create($options); $responses = ["data://text/plain,HTTP/$version 204 No Content\r\n\r\n"]; $pid = http_server('tcp://127.0.0.1:12342', $responses, $output); $fd = fopen('http://127.0.0.1:12342/', 'rb', false, $ctx); fseek($output, 0, SEEK_SET); echo stream_get_contents($output); http_server_kill($pid); } echo "HTTP/1.0, default behaviour:\n"; do_test('1.0', null); echo "HTTP/1.0, connection: close:\n"; do_test('1.0', 'close'); echo "HTTP/1.0, connection: keep-alive:\n"; do_test('1.0', 'keep-alive'); echo "HTTP/1.1, default behaviour:\n"; do_test('1.1', null); echo "HTTP/1.1, connection: close:\n"; do_test('1.1', 'close'); echo "HTTP/1.1, connection: keep-alive:\n"; do_test('1.1', 'keep-alive'); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eXDHL
function name:  (null)
number of ops:  32
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INCLUDE_OR_EVAL                                          'server.inc', REQUIRE
   20     1        ECHO                                                     'HTTP%2F1.0%2C+default+behaviour%3A%0A'
   21     2        INIT_FCALL                                               'do_test'
          3        SEND_VAL                                                 '1.0'
          4        SEND_VAL                                                 null
          5        DO_FCALL                                      0          
   22     6        ECHO                                                     'HTTP%2F1.0%2C+connection%3A+close%3A%0A'
   23     7        INIT_FCALL                                               'do_test'
          8        SEND_VAL                                                 '1.0'
          9        SEND_VAL                                                 'close'
         10        DO_FCALL                                      0          
   24    11        ECHO                                                     'HTTP%2F1.0%2C+connection%3A+keep-alive%3A%0A'
   25    12        INIT_FCALL                                               'do_test'
         13        SEND_VAL                                                 '1.0'
         14        SEND_VAL                                                 'keep-alive'
         15        DO_FCALL                                      0          
   26    16        ECHO                                                     'HTTP%2F1.1%2C+default+behaviour%3A%0A'
   27    17        INIT_FCALL                                               'do_test'
         18        SEND_VAL                                                 '1.1'
         19        SEND_VAL                                                 null
         20        DO_FCALL                                      0          
   28    21        ECHO                                                     'HTTP%2F1.1%2C+connection%3A+close%3A%0A'
   29    22        INIT_FCALL                                               'do_test'
         23        SEND_VAL                                                 '1.1'
         24        SEND_VAL                                                 'close'
         25        DO_FCALL                                      0          
   30    26        ECHO                                                     'HTTP%2F1.1%2C+connection%3A+keep-alive%3A%0A'
   31    27        INIT_FCALL                                               'do_test'
         28        SEND_VAL                                                 '1.1'
         29        SEND_VAL                                                 'keep-alive'
         30        DO_FCALL                                      0          
   32    31      > RETURN                                                   1

Function do_test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/eXDHL
function name:  do_test
number of ops:  46
compiled vars:  !0 = $version, !1 = $connection, !2 = $options, !3 = $ctx, !4 = $responses, !5 = $pid, !6 = $output, !7 = $fd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        INIT_ARRAY                                       ~8      !0, 'protocol_version'
          3        INIT_ARRAY                                       ~9      ~8, 'http'
    4     4        ASSIGN                                                   !2, ~9
    9     5      > JMPZ                                                     !1, ->11
   10     6    >   NOP                                                      
          7        FAST_CONCAT                                      ~13     'Connection%3A+', !1
          8        FETCH_DIM_W                                      $11     !2, 'http'
          9        ASSIGN_DIM                                               $11, 'header'
         10        OP_DATA                                                  ~13
   12    11    >   INIT_FCALL                                               'stream_context_create'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $14     
         14        ASSIGN                                                   !3, $14
   13    15        ROPE_INIT                                     3  ~17     'data%3A%2F%2Ftext%2Fplain%2CHTTP%2F'
         16        ROPE_ADD                                      1  ~17     ~17, !0
         17        ROPE_END                                      2  ~16     ~17, '+204+No+Content%0D%0A%0D%0A'
         18        INIT_ARRAY                                       ~19     ~16
         19        ASSIGN                                                   !4, ~19
   14    20        INIT_FCALL_BY_NAME                                       'http_server'
         21        SEND_VAL_EX                                              'tcp%3A%2F%2F127.0.0.1%3A12342'
         22        SEND_VAR_EX                                              !4
         23        SEND_VAR_EX                                              !6
         24        DO_FCALL                                      0  $21     
         25        ASSIGN                                                   !5, $21
   15    26        INIT_FCALL                                               'fopen'
         27        SEND_VAL                                                 'http%3A%2F%2F127.0.0.1%3A12342%2F'
         28        SEND_VAL                                                 'rb'
         29        SEND_VAL                                                 <false>
         30        SEND_VAR                                                 !3
         31        DO_ICALL                                         $23     
         32        ASSIGN                                                   !7, $23
   16    33        INIT_FCALL                                               'fseek'
         34        SEND_VAR                                                 !6
         35        SEND_VAL                                                 0
         36        SEND_VAL                                                 0
         37        DO_ICALL                                                 
   17    38        INIT_FCALL                                               'stream_get_contents'
         39        SEND_VAR                                                 !6
         40        DO_ICALL                                         $26     
         41        ECHO                                                     $26
   18    42        INIT_FCALL_BY_NAME                                       'http_server_kill'
         43        SEND_VAR_EX                                              !5
         44        DO_FCALL                                      0          
   19    45      > RETURN                                                   null

End of function do_test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
205.47 ms | 1403 KiB | 27 Q