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); if ($debug) { 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 = 30, Position 2 = 53
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 45
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 53
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
Branch analysis from position: 45
Branch analysis from position: 53
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 53
Branch analysis from position: 30
Branch analysis from position: 53
filename:       /in/Cg194
function name:  (null)
number of ops:  103
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
   13    29      > JMPZ                                                     !0, ->53
   14    30    >   ROPE_INIT                                     3  ~16     'var3+%3D+'
         31        ROPE_ADD                                      1  ~16     ~16, !3
         32        ROPE_END                                      2  ~15     ~16, '%0A'
         33        ECHO                                                     ~15
   15    34        INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !4
         36        DO_ICALL                                                 
   16    37        FETCH_DIM_R                                      ~19     !1, 0
         38        IS_EQUAL                                                 !4, ~19
         39      > JMPZ                                                     ~20, ->45
         40    >   ROPE_INIT                                     3  ~23     !3
         41        ROPE_ADD                                      1  ~23     ~23, '+%3D%3D+'
         42        FETCH_DIM_R                                      ~21     !1, 0
         43        ROPE_END                                      2  ~22     ~23, ~21
         44        ECHO                                                     ~22
   17    45    >   INIT_FCALL                                               'strcmp'
         46        SEND_VAR                                                 !4
         47        FETCH_DIM_R                                      ~25     !1, 0
         48        SEND_VAL                                                 ~25
         49        DO_ICALL                                         $26     
         50        BOOL_NOT                                         ~27     $26
         51      > JMPZ                                                     ~27, ->53
         52    >   ECHO                                                     'got+a+match+with+strcmp'
   20    53    >   INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         54        SEND_VAL_EX                                              'a'
         55        SEND_VAL_EX                                              'z'
         56        DO_FCALL                                      0          
   21    57        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         58        SEND_VAL_EX                                              'q111f'
         59        SEND_VAL_EX                                              'fffff'
         60        DO_FCALL                                      0          
   22    61        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         62        SEND_VAR_EX                                              !1
         63        SEND_VAR_EX                                              !2
         64        DO_FCALL                                      0          
   23    65        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         66        CHECK_FUNC_ARG                                           
         67        FETCH_DIM_FUNC_ARG                               $31     !1, 0
         68        SEND_FUNC_ARG                                            $31
         69        SEND_VAR_EX                                              !2
         70        DO_FCALL                                      0          
   24    71        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         72        SEND_VAR_EX                                              !2
         73        SEND_VAR_EX                                              !2
         74        DO_FCALL                                      0          
   26    75        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         76        CHECK_FUNC_ARG                                           
         77        FETCH_DIM_FUNC_ARG                               $34     !1, 0
         78        SEND_FUNC_ARG                                            $34
         79        SEND_VAR_EX                                              !3
         80        DO_FCALL                                      0          
   27    81        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         82        CHECK_FUNC_ARG                                           
         83        FETCH_DIM_FUNC_ARG                               $36     !1, 0
         84        SEND_FUNC_ARG                                            $36
         85        SEND_VAR_EX                                              !4
         86        DO_FCALL                                      0          
   29    87        ECHO                                                     'trying+the+binary+safe+node%21%0A'
   30    88        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         89        CHECK_FUNC_ARG                                           
         90        FETCH_DIM_FUNC_ARG                               $38     !1, 0
         91        SEND_FUNC_ARG                                            $38
         92        SEND_VAR_EX                                              !3
         93        SEND_VAL_EX                                              1
         94        DO_FCALL                                      0          
   31    95        INIT_FCALL_BY_NAME                                       'poor_mans_strcmp'
         96        CHECK_FUNC_ARG                                           
         97        FETCH_DIM_FUNC_ARG                               $40     !1, 0
         98        SEND_FUNC_ARG                                            $40
         99        SEND_VAR_EX                                              !4
        100        SEND_VAL_EX                                              1
        101        DO_FCALL                                      0          
   53   102      > 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/Cg194
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
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      0
   35     3        BIND_GLOBAL                                              !3, 'debug'
   37     4        CONCAT                                           ~7      'a', !0
          5        ASSIGN                                                   !4, ~7
   38     6        CONCAT                                           ~9      'a', !1
          7        ASSIGN                                                   !5, ~9
   40     8      > JMPZ                                                     !2, ->21
   43     9    >   INIT_FCALL                                               'str_replace'
         10        SEND_VAL                                                 '%00'
         11        SEND_VAL                                                 ''
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $11     
         14        ASSIGN                                                   !4, $11
   44    15        INIT_FCALL                                               'str_replace'
         16        SEND_VAL                                                 '%00'
         17        SEND_VAL                                                 ''
         18        SEND_VAR                                                 !5
         19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !5, $13
   46    21    > > JMPZ                                                     !3, ->26
         22    >   INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !4
         24        SEND_VAR                                                 !5
         25        DO_ICALL                                                 
   48    26    >   ASSIGN                                                   !6, 0
   49    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
   50    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
   51    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
   52    54    > > RETURN                                                   !6
   53    55*     > RETURN                                                   null

End of function poor_mans_strcmp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.29 ms | 1408 KiB | 23 Q