3v4l.org

run code in 300+ PHP versions simultaneously
<?php # basic test string_lt('a', 'z'); string_lt('z', 'a'); # numeric strings string_lt('22', '123'); string_lt('123', '22'); # non-numeric strings string_lt('bb', 'abc'); string_lt('abc', 'bb'); # non-numeric strings with numbers in # should be the same as "numeric strings" if strcmp() really does string comparison string_lt('22x', '123x'); string_lt('123x', '22x'); function string_lt($str1, $str2) { # you can't use < operator for comparing strings # wacky stuff will happen $lt_says = ((string) $str1 < (string) $str2); # see what strcmp() says $strcmp_says = strcmp($str1, $str2); echo "$str1 less than $str2; lt_says: $lt_says, strcmp_says: $strcmp_says\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qUSO2
function name:  (null)
number of ops:  33
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL_BY_NAME                                       'string_lt'
          1        SEND_VAL_EX                                              'a'
          2        SEND_VAL_EX                                              'z'
          3        DO_FCALL                                      0          
    5     4        INIT_FCALL_BY_NAME                                       'string_lt'
          5        SEND_VAL_EX                                              'z'
          6        SEND_VAL_EX                                              'a'
          7        DO_FCALL                                      0          
    8     8        INIT_FCALL_BY_NAME                                       'string_lt'
          9        SEND_VAL_EX                                              '22'
         10        SEND_VAL_EX                                              '123'
         11        DO_FCALL                                      0          
    9    12        INIT_FCALL_BY_NAME                                       'string_lt'
         13        SEND_VAL_EX                                              '123'
         14        SEND_VAL_EX                                              '22'
         15        DO_FCALL                                      0          
   12    16        INIT_FCALL_BY_NAME                                       'string_lt'
         17        SEND_VAL_EX                                              'bb'
         18        SEND_VAL_EX                                              'abc'
         19        DO_FCALL                                      0          
   13    20        INIT_FCALL_BY_NAME                                       'string_lt'
         21        SEND_VAL_EX                                              'abc'
         22        SEND_VAL_EX                                              'bb'
         23        DO_FCALL                                      0          
   17    24        INIT_FCALL_BY_NAME                                       'string_lt'
         25        SEND_VAL_EX                                              '22x'
         26        SEND_VAL_EX                                              '123x'
         27        DO_FCALL                                      0          
   18    28        INIT_FCALL_BY_NAME                                       'string_lt'
         29        SEND_VAL_EX                                              '123x'
         30        SEND_VAL_EX                                              '22x'
         31        DO_FCALL                                      0          
   31    32      > RETURN                                                   1

Function string_lt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qUSO2
function name:  string_lt
number of ops:  21
compiled vars:  !0 = $str1, !1 = $str2, !2 = $lt_says, !3 = $strcmp_says
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   25     2        CAST                                          6  ~4      !0
          3        CAST                                          6  ~5      !1
          4        IS_SMALLER                                       ~6      ~4, ~5
          5        ASSIGN                                                   !2, ~6
   28     6        INIT_FCALL                                               'strcmp'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !3, $8
   30    11        ROPE_INIT                                     8  ~11     !0
         12        ROPE_ADD                                      1  ~11     ~11, '+less+than+'
         13        ROPE_ADD                                      2  ~11     ~11, !1
         14        ROPE_ADD                                      3  ~11     ~11, '%3B+lt_says%3A+'
         15        ROPE_ADD                                      4  ~11     ~11, !2
         16        ROPE_ADD                                      5  ~11     ~11, '%2C+strcmp_says%3A+'
         17        ROPE_ADD                                      6  ~11     ~11, !3
         18        ROPE_END                                      7  ~10     ~11, '%0A'
         19        ECHO                                                     ~10
   31    20      > RETURN                                                   null

End of function string_lt

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.63 ms | 1400 KiB | 15 Q