3v4l.org

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

End of function poor_mans_strcmp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.05 ms | 1412 KiB | 23 Q