3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 []= 'wello'; $var2 = 'woodbye wruel world'; $var3 = pack("n*", 0x77, 0x32 + 0x33, 0x6c, 0x6e-2, 0x6f); $var4 = pack('n*', 0x7765, 0x6c6c, 0x6f00); echo "var3 = $var3"; var_dump($var4); if ($var4 == $arr1[0]) {echo "$var3 == $arr1[0]"; } if (! strcmp($var4, $arr1[0])) { echo "got a match with strcmp"; } var_dump(poor_mans_strcmp('a', 'z')); var_dump(poor_mans_strcmp('q111f', 'fffff')); var_dump(poor_mans_strcmp($arr1, $var2)); var_dump(poor_mans_strcmp($arr1[0], $var2)); var_dump(poor_mans_strcmp($var2, $var2)); var_dump(poor_mans_strcmp($arr1[0], $var3)); var_dump(poor_mans_strcmp($arr1[0], $var4)); function poor_mans_strcmp($str1, $str2, $binary_safe = 0) { # use old shell programming trick $str3 = 'a' . $str1; $str4 = 'a' . $str2; if ($binary_safe) { # strip null bytes to make it binary safe! $str3 = str_replace(chr(0), '', $str3); $str4 = str_replace(chr(0), '', $str4); } var_dump($str3, $str4); $result = 0; if ($str3 < $str4) { $result = -1; } if ($str3 > $str4) { if ($result == -1) {echo "Serious error detected, keep on trucking!\n";} $result = 1; } return $result; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 33
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 41
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 33
filename:       /in/mqc43
function name:  (null)
number of ops:  97
compiled vars:  !0 = $arr1, !1 = $var2, !2 = $var3, !3 = $var4
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN_DIM                                               !0
          1        OP_DATA                                                  'wello'
    4     2        ASSIGN                                                   !1, 'woodbye+wruel+world'
    5     3        INIT_FCALL                                               'pack'
          4        SEND_VAL                                                 'n%2A'
          5        SEND_VAL                                                 119
          6        SEND_VAL                                                 101
          7        SEND_VAL                                                 108
          8        SEND_VAL                                                 108
          9        SEND_VAL                                                 111
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !2, $6
    6    12        INIT_FCALL                                               'pack'
         13        SEND_VAL                                                 'n%2A'
         14        SEND_VAL                                                 30565
         15        SEND_VAL                                                 27756
         16        SEND_VAL                                                 28416
         17        DO_ICALL                                         $8      
         18        ASSIGN                                                   !3, $8
    7    19        NOP                                                      
         20        FAST_CONCAT                                      ~10     'var3+%3D+', !2
         21        ECHO                                                     ~10
    8    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !3
         24        DO_ICALL                                                 
    9    25        FETCH_DIM_R                                      ~12     !0, 0
         26        IS_EQUAL                                                 !3, ~12
         27      > JMPZ                                                     ~13, ->33
         28    >   ROPE_INIT                                     3  ~16     !2
         29        ROPE_ADD                                      1  ~16     ~16, '+%3D%3D+'
         30        FETCH_DIM_R                                      ~14     !0, 0
         31        ROPE_END                                      2  ~15     ~16, ~14
         32        ECHO                                                     ~15
   11    33    >   INIT_FCALL                                               'strcmp'
         34        SEND_VAR                                                 !3
         35        FETCH_DIM_R                                      ~18     !0, 0
         36        SEND_VAL                                                 ~18
         37        DO_ICALL                                         $19     
         38        BOOL_NOT                                         ~20     $19
         39      > JMPZ                                                     ~20, ->41
         40    >   ECHO                                                     'got+a+match+with+strcmp'
   12    41    >   INIT_FCALL                                               'var_dump'
         42        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         43        SEND_VAL_EX                                              'a'
         44        SEND_VAL_EX                                              'z'
         45        DO_FCALL                                      0  $21     
         46        SEND_VAR                                                 $21
         47        DO_ICALL                                                 
   13    48        INIT_FCALL                                               'var_dump'
         49        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         50        SEND_VAL_EX                                              'q111f'
         51        SEND_VAL_EX                                              'fffff'
         52        DO_FCALL                                      0  $23     
         53        SEND_VAR                                                 $23
         54        DO_ICALL                                                 
   14    55        INIT_FCALL                                               'var_dump'
         56        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         57        SEND_VAR_EX                                              !0
         58        SEND_VAR_EX                                              !1
         59        DO_FCALL                                      0  $25     
         60        SEND_VAR                                                 $25
         61        DO_ICALL                                                 
   15    62        INIT_FCALL                                               'var_dump'
         63        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         64        CHECK_FUNC_ARG                                           
         65        FETCH_DIM_FUNC_ARG                               $27     !0, 0
         66        SEND_FUNC_ARG                                            $27
         67        SEND_VAR_EX                                              !1
         68        DO_FCALL                                      0  $28     
         69        SEND_VAR                                                 $28
         70        DO_ICALL                                                 
   16    71        INIT_FCALL                                               'var_dump'
         72        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         73        SEND_VAR_EX                                              !1
         74        SEND_VAR_EX                                              !1
         75        DO_FCALL                                      0  $30     
         76        SEND_VAR                                                 $30
         77        DO_ICALL                                                 
   17    78        INIT_FCALL                                               'var_dump'
         79        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         80        CHECK_FUNC_ARG                                           
         81        FETCH_DIM_FUNC_ARG                               $32     !0, 0
         82        SEND_FUNC_ARG                                            $32
         83        SEND_VAR_EX                                              !2
         84        DO_FCALL                                      0  $33     
         85        SEND_VAR                                                 $33
         86        DO_ICALL                                                 
   18    87        INIT_FCALL                                               'var_dump'
         88        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         89        CHECK_FUNC_ARG                                           
         90        FETCH_DIM_FUNC_ARG                               $35     !0, 0
         91        SEND_FUNC_ARG                                            $35
         92        SEND_VAR_EX                                              !3
         93        DO_FCALL                                      0  $36     
         94        SEND_VAR                                                 $36
         95        DO_ICALL                                                 
   38    96      > RETURN                                                   1

Function poor_mans_strcmp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 28
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 34
Branch analysis from position: 28
Branch analysis from position: 20
filename:       /in/mqc43
function name:  poor_mans_strcmp
number of ops:  36
compiled vars:  !0 = $str1, !1 = $str2, !2 = $binary_safe, !3 = $str3, !4 = $str4, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      0
   23     3        CONCAT                                           ~6      'a', !0
          4        ASSIGN                                                   !3, ~6
   24     5        CONCAT                                           ~8      'a', !1
          6        ASSIGN                                                   !4, ~8
   26     7      > JMPZ                                                     !2, ->20
   29     8    >   INIT_FCALL                                               'str_replace'
          9        SEND_VAL                                                 '%00'
         10        SEND_VAL                                                 ''
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $10     
         13        ASSIGN                                                   !3, $10
   30    14        INIT_FCALL                                               'str_replace'
         15        SEND_VAL                                                 '%00'
         16        SEND_VAL                                                 ''
         17        SEND_VAR                                                 !4
         18        DO_ICALL                                         $12     
         19        ASSIGN                                                   !4, $12
   32    20    >   INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !3
         22        SEND_VAR                                                 !4
         23        DO_ICALL                                                 
   34    24        ASSIGN                                                   !5, 0
   35    25        IS_SMALLER                                               !3, !4
         26      > JMPZ                                                     ~16, ->28
         27    >   ASSIGN                                                   !5, -1
   36    28    >   IS_SMALLER                                               !4, !3
         29      > JMPZ                                                     ~18, ->34
         30    >   IS_EQUAL                                                 !5, -1
         31      > JMPZ                                                     ~19, ->33
         32    >   ECHO                                                     'Serious+error+detected%2C+keep+on+trucking%21%0A'
         33    >   ASSIGN                                                   !5, 1
   37    34    > > RETURN                                                   !5
   38    35*     > RETURN                                                   null

End of function poor_mans_strcmp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.56 ms | 1400 KiB | 21 Q