3v4l.org

run code in 300+ PHP versions simultaneously
<?php function var_import($var) { if (strcasecmp($var, 'null') === 0) { return null; } if (strcasecmp($var, 'true') === 0) { return true; } if (strcasecmp($var, 'false') === 0) { return false; } if ($var === ((string) (int) $var)) { return (int) $var; } if ($var === ((string) (float) $var)) { return (float) $var; } return (string) $var; } foreach ([ '1', '2.3', 'true', 'FALSE', 'Null', 'foobar', ] as $var) { ob_start(); var_dump(var_import($var)); echo sprintf('"%s" => %s', $var, trim(ob_get_clean())) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 1, Position 2 = 23
Branch analysis from position: 1
2 jumps found. (Code = 78) Position 1 = 2, Position 2 = 23
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/hg3Xk
function name:  (null)
number of ops:  25
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E > > FE_RESET_R                                       $1      <array>, ->23
          1    > > FE_FETCH_R                                               $1, !0, ->23
   31     2    >   INIT_FCALL                                               'ob_start'
          3        DO_ICALL                                                 
   32     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'var_import'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR                                                 $3
          9        DO_ICALL                                                 
   33    10        INIT_FCALL                                               'sprintf'
         11        SEND_VAL                                                 '%22%25s%22+%3D%3E+%25s'
         12        SEND_VAR                                                 !0
         13        INIT_FCALL                                               'trim'
         14        INIT_FCALL                                               'ob_get_clean'
         15        DO_ICALL                                         $5      
         16        SEND_VAR                                                 $5
         17        DO_ICALL                                         $6      
         18        SEND_VAR                                                 $6
         19        DO_ICALL                                         $7      
         20        CONCAT                                           ~8      $7, '%0A'
         21        ECHO                                                     ~8
   24    22      > JMP                                                      ->1
         23    >   FE_FREE                                                  $1
   34    24      > RETURN                                                   1

Function var_import:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hg3Xk
function name:  var_import
number of ops:  37
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'strcasecmp'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'null'
          4        DO_ICALL                                         $1      
          5        IS_IDENTICAL                                             $1, 0
          6      > JMPZ                                                     ~2, ->8
    6     7    > > RETURN                                                   null
    8     8    >   INIT_FCALL                                               'strcasecmp'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 'true'
         11        DO_ICALL                                         $3      
         12        IS_IDENTICAL                                             $3, 0
         13      > JMPZ                                                     ~4, ->15
    9    14    > > RETURN                                                   <true>
   11    15    >   INIT_FCALL                                               'strcasecmp'
         16        SEND_VAR                                                 !0
         17        SEND_VAL                                                 'false'
         18        DO_ICALL                                         $5      
         19        IS_IDENTICAL                                             $5, 0
         20      > JMPZ                                                     ~6, ->22
   12    21    > > RETURN                                                   <false>
   14    22    >   CAST                                          4  ~7      !0
         23        CAST                                          6  ~8      ~7
         24        IS_IDENTICAL                                             !0, ~8
         25      > JMPZ                                                     ~9, ->28
   15    26    >   CAST                                          4  ~10     !0
         27      > RETURN                                                   ~10
   17    28    >   CAST                                          5  ~11     !0
         29        CAST                                          6  ~12     ~11
         30        IS_IDENTICAL                                             !0, ~12
         31      > JMPZ                                                     ~13, ->34
   18    32    >   CAST                                          5  ~14     !0
         33      > RETURN                                                   ~14
   20    34    >   CAST                                          6  ~15     !0
         35      > RETURN                                                   ~15
   21    36*     > RETURN                                                   null

End of function var_import

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.5 ms | 1403 KiB | 26 Q