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 = int($a->age); $bl = int($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/8W8Jq
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/8W8Jq
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 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8W8Jq
function name:  cmp_obj
number of ops:  24
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        INIT_FCALL_BY_NAME                                       'int'
          3        CHECK_FUNC_ARG                                           
          4        FETCH_OBJ_FUNC_ARG                               $4      !0, 'age'
          5        SEND_FUNC_ARG                                            $4
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !2, $5
   17     8        INIT_FCALL_BY_NAME                                       'int'
          9        CHECK_FUNC_ARG                                           
         10        FETCH_OBJ_FUNC_ARG                               $7      !1, 'age'
         11        SEND_FUNC_ARG                                            $7
         12        DO_FCALL                                      0  $8      
         13        ASSIGN                                                   !3, $8
   18    14        IS_EQUAL                                                 !2, !3
         15      > JMPZ                                                     ~10, ->17
   19    16    > > RETURN                                                   0
   21    17    >   IS_SMALLER                                               !3, !2
         18      > JMPZ                                                     ~11, ->21
         19    >   QM_ASSIGN                                        ~12     1
         20      > JMP                                                      ->22
         21    >   QM_ASSIGN                                        ~12     -1
         22    > > RETURN                                                   ~12
   22    23*     > RETURN                                                   null

End of function cmp_obj

End of class ObjPrueba.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.89 ms | 1392 KiB | 15 Q