3v4l.org

run code in 500+ PHP versions simultaneously
<?php foreach ([ [0, 'a', 'a'], // from https://wiki.php.net/rfc/string_to_number_comparison [0, 0, '0'], [0, 0, '0.0'], [-1, 0, 'foo'], [1, 0, ''], [0, 42, ' 42'], [-1, 42, '42foo'], [0, '0', '0'], [0, '0', '0.0'], [-1, '0', 'foo'], [1, '0', ''], [0, '42', ' 42'], [-1, '42', '42foo'], [0, 42, '000042'], [0, 42, '42.0'], [0, 42.0, '+42.0E0'], [0, 0, '0e214987142012'], [0, '42', '000042'], [0, '42', '42.0'], [0, '42.0', '+42.0E0'], [0, '0', '0e214987142012'], [0, 42, ' 42'], [0, 42, '42 '], [-1, 42, '42abc'], [-1, 42, 'abc42'], [-1, 0, 'abc42'], [0, INF, 'INF'], [0, -INF, '-INF'], [0, INF, '1e1000'], [0, -INF, '-1e1000'], [-1, 10, 20], [-1, '10', 20], [-1, 10, '20'], ] as [$expected, $a, $b]) { $actual = $a <=> $b; if ($expected !== $actual) { echo var_export($a, true).' <=> '.var_export($b, true), PHP_EOL; echo 'Expected: '.var_export($expected, true), PHP_EOL; echo 'Actual: '.var_export($actual, true), PHP_EOL; echo PHP_EOL; } } echo 'Done.', PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 1, Position 2 = 41
Branch analysis from position: 1
2 jumps found. (Code = 78) Position 1 = 2, Position 2 = 41
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 40
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 40
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/dX6Q9
function name:  (null)
number of ops:  45
compiled vars:  !0 = $expected, !1 = $a, !2 = $b, !3 = $actual
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E > > FE_RESET_R                                           $4      <array>, ->41
          1    > > FE_FETCH_R                                                   $4, $5, ->41
          2    >   FETCH_LIST_R                                         $6      $5, 0
   46     3        ASSIGN                                                       !0, $6
          4        FETCH_LIST_R                                         $8      $5, 1
          5        ASSIGN                                                       !1, $8
          6        FETCH_LIST_R                                         $10     $5, 2
          7        ASSIGN                                                       !2, $10
          8        FREE                                                         $5
   47     9        SPACESHIP                                            ~12     !1, !2
         10        ASSIGN                                                       !3, ~12
   48    11        IS_NOT_IDENTICAL                                             !0, !3
         12      > JMPZ                                                         ~14, ->40
   49    13    >   INIT_FCALL                                                   'var_export'
         14        SEND_VAR                                                     !1
         15        SEND_VAL                                                     <true>
         16        DO_ICALL                                             $15     
         17        CONCAT                                               ~16     $15, '+%3C%3D%3E+'
         18        INIT_FCALL                                                   'var_export'
         19        SEND_VAR                                                     !2
         20        SEND_VAL                                                     <true>
         21        DO_ICALL                                             $17     
         22        CONCAT                                               ~18     ~16, $17
         23        ECHO                                                         ~18
         24        ECHO                                                         '%0A'
   50    25        INIT_FCALL                                                   'var_export'
         26        SEND_VAR                                                     !0
         27        SEND_VAL                                                     <true>
         28        DO_ICALL                                             $19     
         29        CONCAT                                               ~20     'Expected%3A+', $19
         30        ECHO                                                         ~20
         31        ECHO                                                         '%0A'
   51    32        INIT_FCALL                                                   'var_export'
         33        SEND_VAR                                                     !3
         34        SEND_VAL                                                     <true>
         35        DO_ICALL                                             $21     
         36        CONCAT                                               ~22     'Actual%3A+++', $21
         37        ECHO                                                         ~22
         38        ECHO                                                         '%0A'
   52    39        ECHO                                                         '%0A'
    4    40    > > JMP                                                          ->1
         41    >   FE_FREE                                                      $4
   55    42        ECHO                                                         'Done.'
         43        ECHO                                                         '%0A'
   56    44      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.06 ms | 2180 KiB | 14 Q