3v4l.org

run code in 300+ PHP versions simultaneously
<?php $debug = 0; if (! $debug) { error_reporting(E_ERROR); } else { error_reporting(E_ALL); } $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\n"; var_dump($var4); if ($var4 == $arr1[0]) {echo "$var3 == $arr1[0]"; } if (! strcmp($var4, $arr1[0])) { echo "got a match with strcmp"; } poor_mans_strcmp('a', 'z'); poor_mans_strcmp('q111f', 'fffff'); poor_mans_strcmp($arr1, $var2); poor_mans_strcmp($arr1[0], $var2); poor_mans_strcmp($var2, $var2); poor_mans_strcmp($arr1[0], $var3); poor_mans_strcmp($arr1[0], $var4); echo "trying the binary safe node!\n"; poor_mans_strcmp($arr1[0], $var3, 1); poor_mans_strcmp($arr1[0], $var4, 1); function poor_mans_strcmp($str1, $str2, $binary_safe = 0) { global $debug; # 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 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 44
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 52
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
Branch analysis from position: 44
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 44
Branch analysis from position: 39
Branch analysis from position: 44
filename:       /in/fIrXb
function name:  (null)
number of ops:  102
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
    4     1        BOOL_NOT                                         ~6      !0
          2      > JMPZ                                                     ~6, ->7
          3    >   INIT_FCALL                                               'error_reporting'
          4        SEND_VAL                                                 1
          5        DO_ICALL                                                 
          6      > JMP                                                      ->10
    5     7    >   INIT_FCALL                                               'error_reporting'
          8        SEND_VAL                                                 32767
          9        DO_ICALL                                                 
    7    10    >   ASSIGN_DIM                                               !1
         11        OP_DATA                                                  'wello'
    8    12        ASSIGN                                                   !2, 'woodbye+wruel+world'
    9    13        INIT_FCALL                                               'pack'
         14        SEND_VAL                                                 'n%2A'
         15        SEND_VAL                                                 119
         16        SEND_VAL                                                 101
         17        SEND_VAL                                                 108
         18        SEND_VAL                                                 108
         19        SEND_VAL                                                 111
         20        DO_ICALL                                         $11     
         21        ASSIGN                                                   !3, $11
   10    22        INIT_FCALL                                               'pack'
         23        SEND_VAL                                                 'n%2A'
         24        SEND_VAL                                                 30565
         25        SEND_VAL                                                 27756
         26        SEND_VAL                                                 28416
         27        DO_ICALL                                         $13     
         28        ASSIGN                                                   !4, $13
   11    29        ROPE_INIT                                     3  ~16     'var3+%3D+'
         30        ROPE_ADD                                      1  ~16     ~16, !3
         31        ROPE_END                                      2  ~15     ~16, '%0A'
         32        ECHO                                                     ~15
   12    33        INIT_FCALL                                               'var_dump'
         34        SEND_VAR                                                 !4
         35        DO_ICALL                                                 
   13    36        FETCH_DIM_R                                      ~19     !1, 0
         37        IS_EQUAL                                                 !4, ~19
         38      > JMPZ                                                     ~20, ->44
         39    >   ROPE_INIT                                     3  ~23     !3
         40        ROPE_ADD                                      1  ~23     ~23, '+%3D%3D+'
         41        FETCH_DIM_R                                      ~21     !1, 0
         42        ROPE_END                                      2  ~22     ~23, ~21
         43        ECHO                                                     ~22
   15    44    >   INIT_FCALL                                               'strcmp'
         45        SEND_VAR                                                 !4
         46        FETCH_DIM_R                                      ~25     !1, 0
         47        SEND_VAL                                                 ~25
         48        DO_ICALL                                         $26     
         49        BOOL_NOT                                         ~27     $26
         50      > JMPZ                                                     ~27, ->52
         51    >   ECHO                                                     'got+a+match+with+strcmp'
   16    52    >   INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         53        SEND_VAL_EX                                              'a'
         54        SEND_VAL_EX                                              'z'
         55        DO_FCALL                                      0          
   17    56        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         57        SEND_VAL_EX                                              'q111f'
         58        SEND_VAL_EX                                              'fffff'
         59        DO_FCALL                                      0          
   18    60        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         61        SEND_VAR_EX                                              !1
         62        SEND_VAR_EX                                              !2
         63        DO_FCALL                                      0          
   19    64        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         65        CHECK_FUNC_ARG                                           
         66        FETCH_DIM_FUNC_ARG                               $31     !1, 0
         67        SEND_FUNC_ARG                                            $31
         68        SEND_VAR_EX                                              !2
         69        DO_FCALL                                      0          
   20    70        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         71        SEND_VAR_EX                                              !2
         72        SEND_VAR_EX                                              !2
         73        DO_FCALL                                      0          
   22    74        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         75        CHECK_FUNC_ARG                                           
         76        FETCH_DIM_FUNC_ARG                               $34     !1, 0
         77        SEND_FUNC_ARG                                            $34
         78        SEND_VAR_EX                                              !3
         79        DO_FCALL                                      0          
   23    80        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         81        CHECK_FUNC_ARG                                           
         82        FETCH_DIM_FUNC_ARG                               $36     !1, 0
         83        SEND_FUNC_ARG                                            $36
         84        SEND_VAR_EX                                              !4
         85        DO_FCALL                                      0          
   25    86        ECHO                                                     'trying+the+binary+safe+node%21%0A'
   26    87        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         88        CHECK_FUNC_ARG                                           
         89        FETCH_DIM_FUNC_ARG                               $38     !1, 0
         90        SEND_FUNC_ARG                                            $38
         91        SEND_VAR_EX                                              !3
         92        SEND_VAL_EX                                              1
         93        DO_FCALL                                      0          
   27    94        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         95        CHECK_FUNC_ARG                                           
         96        FETCH_DIM_FUNC_ARG                               $40     !1, 0
         97        SEND_FUNC_ARG                                            $40
         98        SEND_VAR_EX                                              !4
         99        SEND_VAL_EX                                              1
        100        DO_FCALL                                      0          
   49   101      > RETURN                                                   1

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

End of function poor_mans_strcmp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.33 ms | 1408 KiB | 23 Q