3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test($str, $substr) { var_dump(strpos(substr($str,1), $substr)); return strpos(substr($str,1), $substr) >= 0; } function test2($str, $substr) { return strpos($str, $substr) > 0; } $str = 'hello'; $sub = 'he'; var_dump( test($str, $sub), test2($str, $sub) ); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IKfP7
function name:  (null)
number of ops:  15
compiled vars:  !0 = $str, !1 = $sub
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, 'hello'
   12     1        ASSIGN                                                   !1, 'he'
   14     2        INIT_FCALL                                               'var_dump'
   15     3        INIT_FCALL                                               'test'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
   16     8        INIT_FCALL                                               'test2'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
   18    14      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IKfP7
function name:  test
number of ops:  24
compiled vars:  !0 = $str, !1 = $substr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'strpos'
          4        INIT_FCALL                                               'substr'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 1
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $3      
         11        SEND_VAR                                                 $3
         12        DO_ICALL                                                 
    4    13        INIT_FCALL                                               'strpos'
         14        INIT_FCALL                                               'substr'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 1
         17        DO_ICALL                                         $5      
         18        SEND_VAR                                                 $5
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $6      
         21        IS_SMALLER_OR_EQUAL                              ~7      0, $6
         22      > RETURN                                                   ~7
    5    23*     > RETURN                                                   null

End of function test

Function test2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IKfP7
function name:  test2
number of ops:  9
compiled vars:  !0 = $str, !1 = $substr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        INIT_FCALL                                               'strpos'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6        IS_SMALLER                                       ~3      0, $2
          7      > RETURN                                                   ~3
    9     8*     > RETURN                                                   null

End of function test2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.61 ms | 1403 KiB | 22 Q