3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjPrueba { var $nombre; var $age; function ObjPrueba($nombre, $age) { $this->nombre = $nombre; $this->age = $age; } /* Ésta es la función de comparación estática: */ static function cmp_obj($a, $b) { $al = ($a->age); $bl = ($b->age); if ($al == $bl) { return 0; } return ($al > $bl) ? +1 : -1; } } $a[] = new ObjPrueba("c", 22); $a[] = new ObjPrueba("b", 15); $a[] = new ObjPrueba("d", 2); usort($a, array("ObjPrueba", "cmp_obj")); foreach ($a as $elemento) { echo $elemento->nombre ." -> ". $elemento->age. "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 31
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/eBVK7
function name:  (null)
number of ops:  33
compiled vars:  !0 = $a, !1 = $elemento
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $3      'ObjPrueba'
          1        SEND_VAL_EX                                              'c'
          2        SEND_VAL_EX                                              22
          3        DO_FCALL                                      0          
          4        ASSIGN_DIM                                               !0
          5        OP_DATA                                                  $3
   26     6        NEW                                              $6      'ObjPrueba'
          7        SEND_VAL_EX                                              'b'
          8        SEND_VAL_EX                                              15
          9        DO_FCALL                                      0          
         10        ASSIGN_DIM                                               !0
         11        OP_DATA                                                  $6
   27    12        NEW                                              $9      'ObjPrueba'
         13        SEND_VAL_EX                                              'd'
         14        SEND_VAL_EX                                              2
         15        DO_FCALL                                      0          
         16        ASSIGN_DIM                                               !0
         17        OP_DATA                                                  $9
   29    18        INIT_FCALL                                               'usort'
         19        SEND_REF                                                 !0
         20        SEND_VAL                                                 <array>
         21        DO_ICALL                                                 
   31    22      > FE_RESET_R                                       $12     !0, ->31
         23    > > FE_FETCH_R                                               $12, !1, ->31
   32    24    >   FETCH_OBJ_R                                      ~13     !1, 'nombre'
         25        CONCAT                                           ~14     ~13, '+-%3E+'
         26        FETCH_OBJ_R                                      ~15     !1, 'age'
         27        CONCAT                                           ~16     ~14, ~15
         28        CONCAT                                           ~17     ~16, '%0A'
         29        ECHO                                                     ~17
   31    30      > JMP                                                      ->23
         31    >   FE_FREE                                                  $12
   33    32      > RETURN                                                   1

Class ObjPrueba:
Function objprueba:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eBVK7
function name:  ObjPrueba
number of ops:  7
compiled vars:  !0 = $nombre, !1 = $age
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        ASSIGN_OBJ                                               'nombre'
          3        OP_DATA                                                  !0
   10     4        ASSIGN_OBJ                                               'age'
          5        OP_DATA                                                  !1
   11     6      > RETURN                                                   null

End of function objprueba

Function cmp_obj:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eBVK7
function name:  cmp_obj
number of ops:  16
compiled vars:  !0 = $a, !1 = $b, !2 = $al, !3 = $bl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        FETCH_OBJ_R                                      ~4      !0, 'age'
          3        ASSIGN                                                   !2, ~4
   17     4        FETCH_OBJ_R                                      ~6      !1, 'age'
          5        ASSIGN                                                   !3, ~6
   18     6        IS_EQUAL                                                 !2, !3
          7      > JMPZ                                                     ~8, ->9
   19     8    > > RETURN                                                   0
   21     9    >   IS_SMALLER                                               !3, !2
         10      > JMPZ                                                     ~9, ->13
         11    >   QM_ASSIGN                                        ~10     1
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~10     -1
         14    > > RETURN                                                   ~10
   22    15*     > RETURN                                                   null

End of function cmp_obj

End of class ObjPrueba.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.15 ms | 1400 KiB | 15 Q