3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xmlstr = '<?xml version="1.0"?> <catalog> <car> <title>This is car</title> <price>44.95</price> <model>2018</model> <description>An in-depth look at creating applications with XML.</description> </car> <bike> <title>this is bike</title> <price>33.58</price> <description>Just the dummy description</description> </bike> <wheels> <title>this is wheel</title> <price>33.58</price> <description>Just the dummy description</description> </wheels> <bike> <title>this is bike</title> <price>33.58</price> <description>Just the dummy description</description> </bike> </catalog>'; $xml = simplexml_load_string($xmlstr); foreach ($xml->children() as $product) { if ($product->getName() == 'car') { carFunc($product->title, $product->price, $product->model, $product->description); } if ($product->getName() == 'bike') { bikeFunc($product->title, $product->price, $product->description); } if ($product->getName() == 'wheels') { wheelFunc($product->title, $product->price, $product->description); } } function carFunc($title, $price, $model, $description) { echo "Car: $title: It's a $model selling for $price. In detail: $description\n"; } function bikeFunc($title, $price, $description) { echo "Bike: $title: It sells for $price. In detail: $description\n"; } function wheelFunc($title, $price, $description) { echo "Wheel: $title: It sells for $price. In detail: $description\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 58
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 58
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 42
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 57
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 57
Branch analysis from position: 42
Branch analysis from position: 27
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
filename:       /in/jX0qd
function name:  (null)
number of ops:  60
compiled vars:  !0 = $xmlstr, !1 = $xml, !2 = $product
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22%3F%3E%0A%3Ccatalog%3E%0A+++%3Ccar%3E%0A++++++%3Ctitle%3EThis+is+car%3C%2Ftitle%3E%0A++++++%3Cprice%3E44.95%3C%2Fprice%3E%0A++++++%3Cmodel%3E2018%3C%2Fmodel%3E%0A++++++%3Cdescription%3EAn+in-depth+look+at+creating+applications+with+XML.%3C%2Fdescription%3E%0A+++%3C%2Fcar%3E%0A%0A+++%3Cbike%3E%0A++++++%3Ctitle%3Ethis+is+bike%3C%2Ftitle%3E%0A++++++%3Cprice%3E33.58%3C%2Fprice%3E%0A++++++%3Cdescription%3EJust+the+dummy+description%3C%2Fdescription%3E%0A+++%3C%2Fbike%3E%0A+++%3Cwheels%3E%0A++++++%3Ctitle%3Ethis+is+wheel%3C%2Ftitle%3E%0A++++++%3Cprice%3E33.58%3C%2Fprice%3E%0A++++++%3Cdescription%3EJust+the+dummy+description%3C%2Fdescription%3E%0A+++%3C%2Fwheels%3E%0A%0A+++%3Cbike%3E%0A++++++%3Ctitle%3Ethis+is+bike%3C%2Ftitle%3E%0A++++++%3Cprice%3E33.58%3C%2Fprice%3E%0A++++++%3Cdescription%3EJust+the+dummy+description%3C%2Fdescription%3E%0A+++%3C%2Fbike%3E%0A%0A%0A%3C%2Fcatalog%3E'
   31     1        INIT_FCALL                                               'simplexml_load_string'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   32     5        INIT_METHOD_CALL                                         !1, 'children'
          6        DO_FCALL                                      0  $6      
          7      > FE_RESET_R                                       $7      $6, ->58
          8    > > FE_FETCH_R                                               $7, !2, ->58
   33     9    >   INIT_METHOD_CALL                                         !2, 'getName'
         10        DO_FCALL                                      0  $8      
         11        IS_EQUAL                                                 $8, 'car'
         12      > JMPZ                                                     ~9, ->27
   34    13    >   INIT_FCALL_BY_NAME                                       'carFunc'
         14        CHECK_FUNC_ARG                                           
         15        FETCH_OBJ_FUNC_ARG                               $10     !2, 'title'
         16        SEND_FUNC_ARG                                            $10
         17        CHECK_FUNC_ARG                                           
         18        FETCH_OBJ_FUNC_ARG                               $11     !2, 'price'
         19        SEND_FUNC_ARG                                            $11
         20        CHECK_FUNC_ARG                                           
         21        FETCH_OBJ_FUNC_ARG                               $12     !2, 'model'
         22        SEND_FUNC_ARG                                            $12
         23        CHECK_FUNC_ARG                                           
         24        FETCH_OBJ_FUNC_ARG                               $13     !2, 'description'
         25        SEND_FUNC_ARG                                            $13
         26        DO_FCALL                                      0          
   36    27    >   INIT_METHOD_CALL                                         !2, 'getName'
         28        DO_FCALL                                      0  $15     
         29        IS_EQUAL                                                 $15, 'bike'
         30      > JMPZ                                                     ~16, ->42
   37    31    >   INIT_FCALL_BY_NAME                                       'bikeFunc'
         32        CHECK_FUNC_ARG                                           
         33        FETCH_OBJ_FUNC_ARG                               $17     !2, 'title'
         34        SEND_FUNC_ARG                                            $17
         35        CHECK_FUNC_ARG                                           
         36        FETCH_OBJ_FUNC_ARG                               $18     !2, 'price'
         37        SEND_FUNC_ARG                                            $18
         38        CHECK_FUNC_ARG                                           
         39        FETCH_OBJ_FUNC_ARG                               $19     !2, 'description'
         40        SEND_FUNC_ARG                                            $19
         41        DO_FCALL                                      0          
   39    42    >   INIT_METHOD_CALL                                         !2, 'getName'
         43        DO_FCALL                                      0  $21     
         44        IS_EQUAL                                                 $21, 'wheels'
         45      > JMPZ                                                     ~22, ->57
   40    46    >   INIT_FCALL_BY_NAME                                       'wheelFunc'
         47        CHECK_FUNC_ARG                                           
         48        FETCH_OBJ_FUNC_ARG                               $23     !2, 'title'
         49        SEND_FUNC_ARG                                            $23
         50        CHECK_FUNC_ARG                                           
         51        FETCH_OBJ_FUNC_ARG                               $24     !2, 'price'
         52        SEND_FUNC_ARG                                            $24
         53        CHECK_FUNC_ARG                                           
         54        FETCH_OBJ_FUNC_ARG                               $25     !2, 'description'
         55        SEND_FUNC_ARG                                            $25
         56        DO_FCALL                                      0          
   32    57    > > JMP                                                      ->8
         58    >   FE_FREE                                                  $7
   54    59      > RETURN                                                   1

Function carfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jX0qd
function name:  carFunc
number of ops:  15
compiled vars:  !0 = $title, !1 = $price, !2 = $model, !3 = $description
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   45     4        ROPE_INIT                                     9  ~5      'Car%3A+'
          5        ROPE_ADD                                      1  ~5      ~5, !0
          6        ROPE_ADD                                      2  ~5      ~5, '%3A+It%27s+a+'
          7        ROPE_ADD                                      3  ~5      ~5, !2
          8        ROPE_ADD                                      4  ~5      ~5, '+selling+for+'
          9        ROPE_ADD                                      5  ~5      ~5, !1
         10        ROPE_ADD                                      6  ~5      ~5, '.+In+detail%3A+'
         11        ROPE_ADD                                      7  ~5      ~5, !3
         12        ROPE_END                                      8  ~4      ~5, '%0A'
         13        ECHO                                                     ~4
   46    14      > RETURN                                                   null

End of function carfunc

Function bikefunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jX0qd
function name:  bikeFunc
number of ops:  12
compiled vars:  !0 = $title, !1 = $price, !2 = $description
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   49     3        ROPE_INIT                                     7  ~4      'Bike%3A+'
          4        ROPE_ADD                                      1  ~4      ~4, !0
          5        ROPE_ADD                                      2  ~4      ~4, '%3A+It+sells+for+'
          6        ROPE_ADD                                      3  ~4      ~4, !1
          7        ROPE_ADD                                      4  ~4      ~4, '.+In+detail%3A+'
          8        ROPE_ADD                                      5  ~4      ~4, !2
          9        ROPE_END                                      6  ~3      ~4, '%0A'
         10        ECHO                                                     ~3
   50    11      > RETURN                                                   null

End of function bikefunc

Function wheelfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jX0qd
function name:  wheelFunc
number of ops:  12
compiled vars:  !0 = $title, !1 = $price, !2 = $description
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   53     3        ROPE_INIT                                     7  ~4      'Wheel%3A+'
          4        ROPE_ADD                                      1  ~4      ~4, !0
          5        ROPE_ADD                                      2  ~4      ~4, '%3A+It+sells+for+'
          6        ROPE_ADD                                      3  ~4      ~4, !1
          7        ROPE_ADD                                      4  ~4      ~4, '.+In+detail%3A+'
          8        ROPE_ADD                                      5  ~4      ~4, !2
          9        ROPE_END                                      6  ~3      ~4, '%0A'
         10        ECHO                                                     ~3
   54    11      > RETURN                                                   null

End of function wheelfunc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.01 ms | 949 KiB | 16 Q