3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** Ajax Streaming without polling */ //type octet-stream. make sure apache does not gzip this type, else it would get buffered header('Content-Type: text/octet-stream'); header('Cache-Control: no-cache'); // recommended to prevent caching of event data. /** Send a partial message */ function send_message($id, $message, $progress) { $d = array('message' => $message , 'progress' => $progress); echo json_encode($d) . PHP_EOL; //PUSH THE data out by all FORCE POSSIBLE ob_flush(); flush(); } $serverTime = time(); //LONG RUNNING TASK for($i = 0; $i < 10; $i++) { //Hard work!! sleep(1); //send status message $p = ($i+1)*10; //Progress send_message($serverTime, $p . '% complete. server time: ' . date("h:i:s", time()) , $p); } sleep(1); send_message($serverTime, 'COMPLETE', '100');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 11
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 11
Branch analysis from position: 33
Branch analysis from position: 11
filename:       /in/ACo65
function name:  (null)
number of ops:  42
compiled vars:  !0 = $serverTime, !1 = $i, !2 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'header'
          1        SEND_VAL                                                 'Content-Type%3A+text%2Foctet-stream'
          2        DO_ICALL                                                 
    8     3        INIT_FCALL                                               'header'
          4        SEND_VAL                                                 'Cache-Control%3A+no-cache'
          5        DO_ICALL                                                 
   24     6        INIT_FCALL                                               'time'
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !0, $5
   27     9        ASSIGN                                                   !1, 0
         10      > JMP                                                      ->31
   30    11    >   INIT_FCALL                                               'sleep'
         12        SEND_VAL                                                 1
         13        DO_ICALL                                                 
   33    14        ADD                                              ~9      !1, 1
         15        MUL                                              ~10     ~9, 10
         16        ASSIGN                                                   !2, ~10
   35    17        INIT_FCALL                                               'send_message'
         18        SEND_VAR                                                 !0
         19        CONCAT                                           ~12     !2, '%25+complete.+server+time%3A+'
         20        INIT_FCALL                                               'date'
         21        SEND_VAL                                                 'h%3Ai%3As'
         22        INIT_FCALL                                               'time'
         23        DO_ICALL                                         $13     
         24        SEND_VAR                                                 $13
         25        DO_ICALL                                         $14     
         26        CONCAT                                           ~15     ~12, $14
         27        SEND_VAL                                                 ~15
         28        SEND_VAR                                                 !2
         29        DO_FCALL                                      0          
   27    30        PRE_INC                                                  !1
         31    >   IS_SMALLER                                               !1, 10
         32      > JMPNZ                                                    ~18, ->11
   37    33    >   INIT_FCALL                                               'sleep'
         34        SEND_VAL                                                 1
         35        DO_ICALL                                                 
   38    36        INIT_FCALL                                               'send_message'
         37        SEND_VAR                                                 !0
         38        SEND_VAL                                                 'COMPLETE'
         39        SEND_VAL                                                 '100'
         40        DO_FCALL                                      0          
         41      > RETURN                                                   1

Function send_message:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ACo65
function name:  send_message
number of ops:  16
compiled vars:  !0 = $id, !1 = $message, !2 = $progress, !3 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   15     3        INIT_ARRAY                                       ~4      !1, 'message'
          4        ADD_ARRAY_ELEMENT                                ~4      !2, 'progress'
          5        ASSIGN                                                   !3, ~4
   17     6        INIT_FCALL                                               'json_encode'
          7        SEND_VAR                                                 !3
          8        DO_ICALL                                         $6      
          9        CONCAT                                           ~7      $6, '%0A'
         10        ECHO                                                     ~7
   20    11        INIT_FCALL                                               'ob_flush'
         12        DO_ICALL                                                 
   21    13        INIT_FCALL                                               'flush'
         14        DO_ICALL                                                 
   22    15      > RETURN                                                   null

End of function send_message

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.22 ms | 1403 KiB | 29 Q