3v4l.org

run code in 500+ PHP versions simultaneously
<?php function test($name, $test) { $t = microtime(true); for ($i = 0; $i < 1000000; ++$i) { $test(); } echo sprintf('%.6f', (microtime(true) - $t)), 's ', $name, "\n"; } foreach (['*abcabcabcabcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc', 'a'] as $scalar) { echo '$scalar = ', $scalar, "\n"; test('strpos', function () use ($scalar) { 0 === strpos($scalar, '*'); }); test('strncmp', function () use ($scalar) { 0 === strncmp($scalar, '*', 1); }); test('substr_compare', function () use ($scalar) { true === substr_compare($scalar, '*', 0, 1); }); test('!== && ===', function () use ($scalar) { '' !== $scalar && '*' === $scalar[0]; }); test('=== ??', function () use ($scalar) { '*' === ($scalar[0] ?? null); }); echo "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 1, Position 2 = 37
Branch analysis from position: 1
2 jumps found. (Code = 78) Position 1 = 2, Position 2 = 37
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/RpBM9
function name:  (null)
number of ops:  39
compiled vars:  !0 = $scalar
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E > > FE_RESET_R                                           $1      <array>, ->37
          1    > > FE_FETCH_R                                                   $1, !0, ->37
   14     2    >   ECHO                                                         '%24scalar+%3D+'
          3        ECHO                                                         !0
          4        ECHO                                                         '%0A'
   16     5        INIT_FCALL                                                   'test'
          6        SEND_VAL                                                     'strpos'
          7        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          8        BIND_LEXICAL                                                 ~2, !0
          9        SEND_VAL                                                     ~2
         10        DO_FCALL                                          0          
   17    11        INIT_FCALL                                                   'test'
         12        SEND_VAL                                                     'strncmp'
         13        DECLARE_LAMBDA_FUNCTION                              ~4      [1]
         14        BIND_LEXICAL                                                 ~4, !0
         15        SEND_VAL                                                     ~4
         16        DO_FCALL                                          0          
   18    17        INIT_FCALL                                                   'test'
         18        SEND_VAL                                                     'substr_compare'
         19        DECLARE_LAMBDA_FUNCTION                              ~6      [2]
         20        BIND_LEXICAL                                                 ~6, !0
         21        SEND_VAL                                                     ~6
         22        DO_FCALL                                          0          
   19    23        INIT_FCALL                                                   'test'
         24        SEND_VAL                                                     '%21%3D%3D+%26%26+%3D%3D%3D'
         25        DECLARE_LAMBDA_FUNCTION                              ~8      [3]
         26        BIND_LEXICAL                                                 ~8, !0
         27        SEND_VAL                                                     ~8
         28        DO_FCALL                                          0          
   20    29        INIT_FCALL                                                   'test'
         30        SEND_VAL                                                     '%3D%3D%3D+%3F%3F'
         31        DECLARE_LAMBDA_FUNCTION                              ~10     [4]
         32        BIND_LEXICAL                                                 ~10, !0
         33        SEND_VAL                                                     ~10
         34        DO_FCALL                                          0          
   22    35        ECHO                                                         '%0A'
   13    36      > JMP                                                          ->1
         37    >   FE_FREE                                                      $1
   23    38      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RpBM9
function name:  {closure:/in/RpBM9:16}
number of ops:  5
compiled vars:  !0 = $scalar
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   BIND_STATIC                                                  !0
          1        FRAMELESS_ICALL_2                strpos              ~1      !0, '%2A'
          2        IS_IDENTICAL                                         ~2      ~1, 0
          3        FREE                                                         ~2
          4      > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RpBM9
function name:  {closure:/in/RpBM9:17}
number of ops:  9
compiled vars:  !0 = $scalar
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   BIND_STATIC                                                  !0
          1        INIT_FCALL                                                   'strncmp'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     '%2A'
          4        SEND_VAL                                                     1
          5        DO_ICALL                                             $1      
          6        IS_IDENTICAL                                         ~2      $1, 0
          7        FREE                                                         ~2
          8      > RETURN                                                       null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RpBM9
function name:  {closure:/in/RpBM9:18}
number of ops:  10
compiled vars:  !0 = $scalar
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   BIND_STATIC                                                  !0
          1        INIT_FCALL                                                   'substr_compare'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     '%2A'
          4        SEND_VAL                                                     0
          5        SEND_VAL                                                     1
          6        DO_ICALL                                             $1      
          7        TYPE_CHECK                                        8  ~2      $1
          8        FREE                                                         ~2
          9      > RETURN                                                       null

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/RpBM9
function name:  {closure:/in/RpBM9:19}
number of ops:  7
compiled vars:  !0 = $scalar
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   BIND_STATIC                                                  !0
          1        IS_NOT_IDENTICAL                                     ~1      !0, ''
          2      > JMPZ_EX                                              ~1      ~1, ->6
          3    >   FETCH_DIM_R                                          ~2      !0, 0
          4        IS_IDENTICAL                                         ~3      ~2, '%2A'
          5        BOOL                                                 ~1      ~3
          6    > > RETURN                                                       null

End of Dynamic Function 3

Dynamic Function 4
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RpBM9
function name:  {closure:/in/RpBM9:20}
number of ops:  7
compiled vars:  !0 = $scalar
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   BIND_STATIC                                                  !0
          1        FETCH_DIM_IS                                         ~1      !0, 0
          2        COALESCE                                             ~2      ~1
          3        QM_ASSIGN                                            ~2      null
          4        IS_IDENTICAL                                         ~3      ~2, '%2A'
          5        FREE                                                         ~3
          6      > RETURN                                                       null

End of Dynamic Function 4

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 8
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 8
Branch analysis from position: 13
Branch analysis from position: 8
filename:       /in/RpBM9
function name:  test
number of ops:  26
compiled vars:  !0 = $name, !1 = $test, !2 = $t, !3 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    4     2        INIT_FCALL                                                   'microtime'
          3        SEND_VAL                                                     <true>
          4        DO_ICALL                                             $4      
          5        ASSIGN                                                       !2, $4
    6     6        ASSIGN                                                       !3, 0
          7      > JMP                                                          ->11
    7     8    >   INIT_DYNAMIC_CALL                                            !1
          9        DO_FCALL                                          0          
    6    10        PRE_INC                                                      !3
         11    >   IS_SMALLER                                                   !3, 1000000
         12      > JMPNZ                                                        ~9, ->8
   10    13    >   INIT_FCALL                                                   'sprintf'
         14        SEND_VAL                                                     '%25.6f'
         15        INIT_FCALL                                                   'microtime'
         16        SEND_VAL                                                     <true>
         17        DO_ICALL                                             $10     
         18        SUB                                                  ~11     $10, !2
         19        SEND_VAL                                                     ~11
         20        DO_ICALL                                             $12     
         21        ECHO                                                         $12
         22        ECHO                                                         's+'
         23        ECHO                                                         !0
         24        ECHO                                                         '%0A'
   11    25      > RETURN                                                       null

End of function test

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
154.83 ms | 693 KiB | 20 Q