3v4l.org

run code in 300+ PHP versions simultaneously
<?php say("strcmp(str1, str2): Returns < 0 if str1 is less than str2;\n", " > 0 if str1 is greater than str2, and 0 if they are equal.\n", " http://php.net/manual/en/function.strcmp.php"); say( "basic test"); string_lt('a', 'z'); say("numeric strings"); string_lt('22', '123'); say("non-numeric strings"); string_lt('bb', 'abc'); say("non-numeric strings with numbers in"); say("should be the same as 'numeric strings' if strcmp() really does string comparison"); string_lt('22x', '123x'); say("numbers"); string_lt(22, 123); function string_lt($str1, $str2) { # < operator if ($str1 < $str2) { say("$str1 < $str2"); } if ($str2 < $str1) { say("$str2 < $str1"); } # good old strcmp() if (strcmp($str1, $str2) < 0) { say("strcmp says: $str1 < $str2"); } if (strcmp($str2, $str1) < 0) { say("strcmp says: $str2 < $str1"); } } function say() { $msgs = func_get_args(); foreach ($msgs as $msg) { echo $msg; } echo "\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KinDE
function name:  (null)
number of ops:  44
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'say'
          1        SEND_VAL_EX                                              'strcmp%28str1%2C+str2%29%3A+Returns+%3C+0+if+str1+is+less+than+str2%3B%0A'
    4     2        SEND_VAL_EX                                              '+%3E+0+if+str1+is+greater+than+str2%2C+and+0+if+they+are+equal.%0A'
    5     3        SEND_VAL_EX                                              '+http%3A%2F%2Fphp.net%2Fmanual%2Fen%2Ffunction.strcmp.php'
          4        DO_FCALL                                      0          
    7     5        INIT_FCALL_BY_NAME                                       'say'
          6        SEND_VAL_EX                                              'basic+test'
          7        DO_FCALL                                      0          
    8     8        INIT_FCALL_BY_NAME                                       'string_lt'
          9        SEND_VAL_EX                                              'a'
         10        SEND_VAL_EX                                              'z'
         11        DO_FCALL                                      0          
   11    12        INIT_FCALL_BY_NAME                                       'say'
         13        SEND_VAL_EX                                              'numeric+strings'
         14        DO_FCALL                                      0          
   12    15        INIT_FCALL_BY_NAME                                       'string_lt'
         16        SEND_VAL_EX                                              '22'
         17        SEND_VAL_EX                                              '123'
         18        DO_FCALL                                      0          
   15    19        INIT_FCALL_BY_NAME                                       'say'
         20        SEND_VAL_EX                                              'non-numeric+strings'
         21        DO_FCALL                                      0          
   16    22        INIT_FCALL_BY_NAME                                       'string_lt'
         23        SEND_VAL_EX                                              'bb'
         24        SEND_VAL_EX                                              'abc'
         25        DO_FCALL                                      0          
   19    26        INIT_FCALL_BY_NAME                                       'say'
         27        SEND_VAL_EX                                              'non-numeric+strings+with+numbers+in'
         28        DO_FCALL                                      0          
   20    29        INIT_FCALL_BY_NAME                                       'say'
         30        SEND_VAL_EX                                              'should+be+the+same+as+%27numeric+strings%27+if+strcmp%28%29+really+does+string+comparison'
         31        DO_FCALL                                      0          
   21    32        INIT_FCALL_BY_NAME                                       'string_lt'
         33        SEND_VAL_EX                                              '22x'
         34        SEND_VAL_EX                                              '123x'
         35        DO_FCALL                                      0          
   23    36        INIT_FCALL_BY_NAME                                       'say'
         37        SEND_VAL_EX                                              'numbers'
         38        DO_FCALL                                      0          
   24    39        INIT_FCALL_BY_NAME                                       'string_lt'
         40        SEND_VAL_EX                                              22
         41        SEND_VAL_EX                                              123
         42        DO_FCALL                                      0          
   48    43      > RETURN                                                   1

Function string_lt:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 44
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
Branch analysis from position: 31
Branch analysis from position: 18
Branch analysis from position: 10
filename:       /in/KinDE
function name:  string_lt
number of ops:  45
compiled vars:  !0 = $str1, !1 = $str2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   30     2        IS_SMALLER                                               !0, !1
          3      > JMPZ                                                     ~2, ->10
          4    >   INIT_FCALL_BY_NAME                                       'say'
          5        ROPE_INIT                                     3  ~4      !0
          6        ROPE_ADD                                      1  ~4      ~4, '+%3C+'
          7        ROPE_END                                      2  ~3      ~4, !1
          8        SEND_VAL_EX                                              ~3
          9        DO_FCALL                                      0          
   31    10    >   IS_SMALLER                                               !1, !0
         11      > JMPZ                                                     ~7, ->18
         12    >   INIT_FCALL_BY_NAME                                       'say'
         13        ROPE_INIT                                     3  ~9      !1
         14        ROPE_ADD                                      1  ~9      ~9, '+%3C+'
         15        ROPE_END                                      2  ~8      ~9, !0
         16        SEND_VAL_EX                                              ~8
         17        DO_FCALL                                      0          
   34    18    >   INIT_FCALL                                               'strcmp'
         19        SEND_VAR                                                 !0
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $12     
         22        IS_SMALLER                                               $12, 0
         23      > JMPZ                                                     ~13, ->31
         24    >   INIT_FCALL_BY_NAME                                       'say'
         25        ROPE_INIT                                     4  ~15     'strcmp+says%3A+'
         26        ROPE_ADD                                      1  ~15     ~15, !0
         27        ROPE_ADD                                      2  ~15     ~15, '+%3C+'
         28        ROPE_END                                      3  ~14     ~15, !1
         29        SEND_VAL_EX                                              ~14
         30        DO_FCALL                                      0          
   35    31    >   INIT_FCALL                                               'strcmp'
         32        SEND_VAR                                                 !1
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                         $18     
         35        IS_SMALLER                                               $18, 0
         36      > JMPZ                                                     ~19, ->44
         37    >   INIT_FCALL_BY_NAME                                       'say'
         38        ROPE_INIT                                     4  ~21     'strcmp+says%3A+'
         39        ROPE_ADD                                      1  ~21     ~21, !1
         40        ROPE_ADD                                      2  ~21     ~21, '+%3C+'
         41        ROPE_END                                      3  ~20     ~21, !0
         42        SEND_VAL_EX                                              ~20
         43        DO_FCALL                                      0          
   36    44    > > RETURN                                                   null

End of function string_lt

Function say:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/KinDE
function name:  say
number of ops:  9
compiled vars:  !0 = $msgs, !1 = $msg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   FUNC_GET_ARGS                                    ~2      
          1        ASSIGN                                                   !0, ~2
   43     2      > FE_RESET_R                                       $4      !0, ->6
          3    > > FE_FETCH_R                                               $4, !1, ->6
   45     4    >   ECHO                                                     !1
   43     5      > JMP                                                      ->3
          6    >   FE_FREE                                                  $4
   47     7        ECHO                                                     '%0A'
   48     8      > RETURN                                                   null

End of function say

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.58 ms | 1396 KiB | 15 Q