3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array=array("number"=>"3","string"=>"abc","null"=>null); $ncache=array(); $scache=array(); foreach(range(1,10000) as $it) { $ncache[]=$array; $scache[]=$array; } function ncompress(&$v) { if(is_numeric($v)) $v=floatval($v); elseif(is_string($v)) $v=trim($v); elseif(is_null($v)) $v=null; } function scompress(&$v) { if(is_numeric($v)) $v=floatval($v); elseif(is_string($v)) $v=trim($v); elseif(is_null($v)) $v=""; } array_walk_recursive($ncache,"ncompress"); array_walk_recursive($scache,"scompress"); echo "Length of null : ".strlen(json_encode($ncache)).' ('.strlen(gzdeflate(json_encode($ncache))).')'; echo "\n"; echo "Length of string: ".strlen(json_encode($scache)).' ('.strlen(gzdeflate(json_encode($scache))).')';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/jvMIH
function name:  (null)
number of ops:  57
compiled vars:  !0 = $array, !1 = $ncache, !2 = $scache, !3 = $it
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    4     2        ASSIGN                                                   !2, <array>
    5     3        INIT_FCALL                                               'range'
          4        SEND_VAL                                                 1
          5        SEND_VAL                                                 10000
          6        DO_ICALL                                         $7      
          7      > FE_RESET_R                                       $8      $7, ->14
          8    > > FE_FETCH_R                                               $8, !3, ->14
    7     9    >   ASSIGN_DIM                                               !1
         10        OP_DATA                                                  !0
    8    11        ASSIGN_DIM                                               !2
         12        OP_DATA                                                  !0
    5    13      > JMP                                                      ->8
         14    >   FE_FREE                                                  $8
   22    15        INIT_FCALL                                               'array_walk_recursive'
         16        SEND_REF                                                 !1
         17        SEND_VAL                                                 'ncompress'
         18        DO_ICALL                                                 
   23    19        INIT_FCALL                                               'array_walk_recursive'
         20        SEND_REF                                                 !2
         21        SEND_VAL                                                 'scompress'
         22        DO_ICALL                                                 
   24    23        INIT_FCALL                                               'json_encode'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $13     
         26        STRLEN                                           ~14     $13
         27        CONCAT                                           ~15     'Length+of+null++%3A+', ~14
         28        CONCAT                                           ~16     ~15, '+%28'
         29        INIT_FCALL                                               'gzdeflate'
         30        INIT_FCALL                                               'json_encode'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                         $17     
         33        SEND_VAR                                                 $17
         34        DO_ICALL                                         $18     
         35        STRLEN                                           ~19     $18
         36        CONCAT                                           ~20     ~16, ~19
         37        CONCAT                                           ~21     ~20, '%29'
         38        ECHO                                                     ~21
   25    39        ECHO                                                     '%0A'
   26    40        INIT_FCALL                                               'json_encode'
         41        SEND_VAR                                                 !2
         42        DO_ICALL                                         $22     
         43        STRLEN                                           ~23     $22
         44        CONCAT                                           ~24     'Length+of+string%3A+', ~23
         45        CONCAT                                           ~25     ~24, '+%28'
         46        INIT_FCALL                                               'gzdeflate'
         47        INIT_FCALL                                               'json_encode'
         48        SEND_VAR                                                 !2
         49        DO_ICALL                                         $26     
         50        SEND_VAR                                                 $26
         51        DO_ICALL                                         $27     
         52        STRLEN                                           ~28     $27
         53        CONCAT                                           ~29     ~25, ~28
         54        CONCAT                                           ~30     ~29, '%29'
         55        ECHO                                                     ~30
         56      > RETURN                                                   1

Function ncompress:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/jvMIH
function name:  ncompress
number of ops:  19
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'is_numeric'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > JMPZ                                                     $1, ->8
          5    >   CAST                                          5  ~2      !0
          6        ASSIGN                                                   !0, ~2
          7      > JMP                                                      ->18
   13     8    >   TYPE_CHECK                                   64          !0
          9      > JMPZ                                                     ~4, ->15
         10    >   INIT_FCALL                                               'trim'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $5      
         13        ASSIGN                                                   !0, $5
         14      > JMP                                                      ->18
   14    15    >   TYPE_CHECK                                    2          !0
         16      > JMPZ                                                     ~7, ->18
         17    >   ASSIGN                                                   !0, null
   15    18    > > RETURN                                                   null

End of function ncompress

Function scompress:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/jvMIH
function name:  scompress
number of ops:  19
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'is_numeric'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > JMPZ                                                     $1, ->8
          5    >   CAST                                          5  ~2      !0
          6        ASSIGN                                                   !0, ~2
          7      > JMP                                                      ->18
   19     8    >   TYPE_CHECK                                   64          !0
          9      > JMPZ                                                     ~4, ->15
         10    >   INIT_FCALL                                               'trim'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $5      
         13        ASSIGN                                                   !0, $5
         14      > JMP                                                      ->18
   20    15    >   TYPE_CHECK                                    2          !0
         16      > JMPZ                                                     ~7, ->18
         17    >   ASSIGN                                                   !0, ''
   21    18    > > RETURN                                                   null

End of function scompress

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.89 ms | 1404 KiB | 25 Q