3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyXML extends SimpleXMLElement { public function firstChild() { $children = $this->children(); foreach ($children as $child) break; return $child; } public function keyHasTwins($key) { if (isset($this->$key)) return (count($this->$key)>1); else return false; } } $s = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>'. '<request>'. ' <body>'. ' <rows>'. ' <row id="1"/>'. ' <row id="2"/>'. ' <row id="3"/>'. ' <row2 ver="2.0">test data</row2>'. ' </rows>'. ' </body>'. '</request>'; $obj = new MyXML($s); $rows = $obj->firstChild()->firstChild()->children(); var_dump($rows->keyHasTwins('row')); var_dump($rows->keyHasTwins('row2')); var_dump($rows->keyHasTwins('my-row'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qYcA2
function name:  (null)
number of ops:  31
compiled vars:  !0 = $s, !1 = $obj, !2 = $rows
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22utf-8%22+standalone%3D%22yes%22+%3F%3E%3Crequest%3E++%3Cbody%3E++++++%3Crows%3E++++++++++%3Crow+id%3D%221%22%2F%3E++++++++++%3Crow+id%3D%222%22%2F%3E++++++++++%3Crow+id%3D%223%22%2F%3E++++++++++%3Crow2+ver%3D%222.0%22%3Etest+data%3C%2Frow2%3E++++++%3C%2Frows%3E++%3C%2Fbody%3E%3C%2Frequest%3E'
   34     1        NEW                                              $4      'MyXML'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
   35     5        INIT_METHOD_CALL                                         !1, 'firstChild'
          6        DO_FCALL                                      0  $7      
          7        INIT_METHOD_CALL                                         $7, 'firstChild'
          8        DO_FCALL                                      0  $8      
          9        INIT_METHOD_CALL                                         $8, 'children'
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !2, $9
   37    12        INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !2, 'keyHasTwins'
         14        SEND_VAL_EX                                              'row'
         15        DO_FCALL                                      0  $11     
         16        SEND_VAR                                                 $11
         17        DO_ICALL                                                 
   38    18        INIT_FCALL                                               'var_dump'
         19        INIT_METHOD_CALL                                         !2, 'keyHasTwins'
         20        SEND_VAL_EX                                              'row2'
         21        DO_FCALL                                      0  $13     
         22        SEND_VAR                                                 $13
         23        DO_ICALL                                                 
   39    24        INIT_FCALL                                               'var_dump'
         25        INIT_METHOD_CALL                                         !2, 'keyHasTwins'
         26        SEND_VAL_EX                                              'my-row'
         27        DO_FCALL                                      0  $15     
         28        SEND_VAR                                                 $15
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Class MyXML:
Function firstchild:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
Branch analysis from position: 7
filename:       /in/qYcA2
function name:  firstChild
number of ops:  10
compiled vars:  !0 = $children, !1 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_METHOD_CALL                                         'children'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
    7     3      > FE_RESET_R                                       $4      !0, ->7
          4    > > FE_FETCH_R                                               $4, !1, ->7
    8     5    > > JMP                                                      ->7
    7     6*       JMP                                                      ->4
          7    >   FE_FREE                                                  $4
    9     8      > RETURN                                                   !1
   10     9*     > RETURN                                                   null

End of function firstchild

Function keyhastwins:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qYcA2
function name:  keyHasTwins
number of ops:  10
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        ISSET_ISEMPTY_PROP_OBJ                                   !0
          2      > JMPZ                                                     ~1, ->8
   15     3    >   FETCH_OBJ_R                                      ~2      !0
          4        COUNT                                            ~3      ~2
          5        IS_SMALLER                                       ~4      1, ~3
          6      > RETURN                                                   ~4
          7*       JMP                                                      ->9
   17     8    > > RETURN                                                   <false>
   18     9*     > RETURN                                                   null

End of function keyhastwins

End of class MyXML.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.75 ms | 1400 KiB | 15 Q