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) { return (bool)count($this->$key); } } $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'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q5g2D
function name:  (null)
number of ops:  19
compiled vars:  !0 = $s, !1 = $obj, !2 = $rows
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     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'
   31     1        NEW                                              $4      'MyXML'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
   32     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
   34    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                                                 
         18      > 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/q5g2D
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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q5g2D
function name:  keyHasTwins
number of ops:  6
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      !0
          2        COUNT                                            ~2      ~1
          3        BOOL                                             ~3      ~2
          4      > RETURN                                                   ~3
   15     5*     > RETURN                                                   null

End of function keyhastwins

End of class MyXML.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.53 ms | 1392 KiB | 15 Q