3v4l.org

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

End of function poor_mans_strcmp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160 ms | 1412 KiB | 21 Q