3v4l.org

run code in 300+ PHP versions simultaneously
<?php class WP_Term { public $foo = 'foo'; public $data; // Change the visibility to protected or private and the script will throw an error. } $_POST['action'] = 'action'; function wp_parse_args( $args, $defaults = array() ) { if ( is_object( $args ) ) { $parsed_args = get_object_vars( $args ); } elseif ( is_array( $args ) ) { $parsed_args =& $args; } else { wp_parse_str( $args, $parsed_args ); } if ( is_array( $defaults ) && $defaults ) { return array_merge( $defaults, $parsed_args ); } return $parsed_args; } class WP_Ajax_Response { public $responses = array(); public function add( $args = '' ) { $defaults = array( 'what' => 'object', 'action' => false, 'id' => '0', 'old_id' => false, 'position' => 1, 'data' => '', 'supplemental' => array(), ); $parsed_args = wp_parse_args( $args, $defaults ); $position = preg_replace( '/[^a-z0-9:_-]/i', '', $parsed_args['position'] ); $id = $parsed_args['id']; $what = $parsed_args['what']; $action = $parsed_args['action']; $old_id = $parsed_args['old_id']; $data = $parsed_args['data']; $response = "<response_data><![CDATA[$data]]></response_data>"; $s = ''; if ( is_array( $parsed_args['supplemental'] ) ) { foreach ( $parsed_args['supplemental'] as $k => $v ) { $s .= "<$k><![CDATA[$v]]></$k>"; } $s = "<supplemental>$s</supplemental>"; } if ( false === $action ) { $action = $_POST['action']; } $x = ''; $x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action. $x .= "<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>"; $x .= $response; $x .= $s; $x .= "</$what>"; $x .= '</response>'; $this->responses[] = $x; return $x; } } $response = new WP_Ajax_Response(); $tag = new WP_Term(); $response->add( array( 'what' => 'term', 'supplemental' => (array) $tag, ) ); libxml_use_internal_errors( true ); $xml = simplexml_load_string( $response->responses[0], 'SimpleXMLElement' ); if ( $xml === false ) { echo 'Failed loading XML: '; foreach ( libxml_get_errors() as $error ) { // Display each error echo '<br>', $error->message . "\n"; } // Clear the error buffer to free memory libxml_clear_errors(); } else { // Your XML is correctly parsed, proceed with your logic echo 'XML loaded successfully.' . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 41
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XQL4f
function name:  (null)
number of ops:  43
compiled vars:  !0 = $response, !1 = $tag, !2 = $xml, !3 = $error
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_W                      global              $4      '_POST'
          1        ASSIGN_DIM                                               $4, 'action'
          2        OP_DATA                                                  'action'
   77     3        NEW                                              $6      'WP_Ajax_Response'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $6
   78     6        NEW                                              $9      'WP_Term'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $9
   80     9        INIT_METHOD_CALL                                         !0, 'add'
   82    10        INIT_ARRAY                                       ~12     'term', 'what'
   83    11        CAST                                          7  ~13     !1
         12        ADD_ARRAY_ELEMENT                                ~12     ~13, 'supplemental'
         13        SEND_VAL_EX                                              ~12
   80    14        DO_FCALL                                      0          
   87    15        INIT_FCALL                                               'libxml_use_internal_errors'
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                                 
   88    18        INIT_FCALL                                               'simplexml_load_string'
         19        FETCH_OBJ_R                                      ~16     !0, 'responses'
         20        FETCH_DIM_R                                      ~17     ~16, 0
         21        SEND_VAL                                                 ~17
         22        SEND_VAL                                                 'SimpleXMLElement'
         23        DO_ICALL                                         $18     
         24        ASSIGN                                                   !2, $18
   90    25        TYPE_CHECK                                    4          !2
         26      > JMPZ                                                     ~20, ->41
   91    27    >   ECHO                                                     'Failed+loading+XML%3A+'
   92    28        INIT_FCALL                                               'libxml_get_errors'
         29        DO_ICALL                                         $21     
         30      > FE_RESET_R                                       $22     $21, ->37
         31    > > FE_FETCH_R                                               $22, !3, ->37
   94    32    >   ECHO                                                     '%3Cbr%3E'
         33        FETCH_OBJ_R                                      ~23     !3, 'message'
         34        CONCAT                                           ~24     ~23, '%0A'
         35        ECHO                                                     ~24
   92    36      > JMP                                                      ->31
         37    >   FE_FREE                                                  $22
   97    38        INIT_FCALL                                               'libxml_clear_errors'
         39        DO_ICALL                                                 
   90    40      > JMP                                                      ->42
  100    41    >   ECHO                                                     'XML+loaded+successfully.%0A'
  101    42    > > RETURN                                                   1

Function wp_parse_args:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
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 = 17
Branch analysis from position: 17
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
Branch analysis from position: 20
filename:       /in/XQL4f
function name:  wp_parse_args
number of ops:  28
compiled vars:  !0 = $args, !1 = $defaults, !2 = $parsed_args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   11     2        TYPE_CHECK                                  256          !0
          3      > JMPZ                                                     ~3, ->9
   12     4    >   INIT_FCALL                                               'get_object_vars'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !2, $4
   11     8      > JMP                                                      ->17
   13     9    >   TYPE_CHECK                                  128          !0
         10      > JMPZ                                                     ~6, ->13
   14    11    >   ASSIGN_REF                                               !2, !0
   13    12      > JMP                                                      ->17
   16    13    >   INIT_FCALL_BY_NAME                                       'wp_parse_str'
         14        SEND_VAR_EX                                              !0
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0          
   19    17    >   TYPE_CHECK                                  128  ~9      !1
         18      > JMPZ_EX                                          ~9      ~9, ->20
         19    >   BOOL                                             ~9      !1
         20    > > JMPZ                                                     ~9, ->26
   20    21    >   INIT_FCALL                                               'array_merge'
         22        SEND_VAR                                                 !1
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $10     
         25      > RETURN                                                   $10
   23    26    > > RETURN                                                   !2
   24    27*     > RETURN                                                   null

End of function wp_parse_args

Class WP_Term: [no user functions]
Class WP_Ajax_Response:
Function add:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 50
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 45
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 45
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 55
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 71
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
Branch analysis from position: 45
Branch analysis from position: 50
filename:       /in/XQL4f
function name:  add
number of ops:  93
compiled vars:  !0 = $args, !1 = $defaults, !2 = $parsed_args, !3 = $position, !4 = $id, !5 = $what, !6 = $action, !7 = $old_id, !8 = $data, !9 = $response, !10 = $s, !11 = $v, !12 = $k, !13 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV_INIT                                        !0      ''
   31     1        ASSIGN                                                   !1, <array>
   41     2        INIT_FCALL                                               'wp_parse_args'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $15     
          6        ASSIGN                                                   !2, $15
   43     7        INIT_FCALL                                               'preg_replace'
          8        SEND_VAL                                                 '%2F%5B%5Ea-z0-9%3A_-%5D%2Fi'
          9        SEND_VAL                                                 ''
         10        FETCH_DIM_R                                      ~17     !2, 'position'
         11        SEND_VAL                                                 ~17
         12        DO_ICALL                                         $18     
         13        ASSIGN                                                   !3, $18
   44    14        FETCH_DIM_R                                      ~20     !2, 'id'
         15        ASSIGN                                                   !4, ~20
   45    16        FETCH_DIM_R                                      ~22     !2, 'what'
         17        ASSIGN                                                   !5, ~22
   46    18        FETCH_DIM_R                                      ~24     !2, 'action'
         19        ASSIGN                                                   !6, ~24
   47    20        FETCH_DIM_R                                      ~26     !2, 'old_id'
         21        ASSIGN                                                   !7, ~26
   48    22        FETCH_DIM_R                                      ~28     !2, 'data'
         23        ASSIGN                                                   !8, ~28
   50    24        ROPE_INIT                                     3  ~31     '%3Cresponse_data%3E%3C%21%5BCDATA%5B'
         25        ROPE_ADD                                      1  ~31     ~31, !8
         26        ROPE_END                                      2  ~30     ~31, '%5D%5D%3E%3C%2Fresponse_data%3E'
         27        ASSIGN                                                   !9, ~30
   52    28        ASSIGN                                                   !10, ''
   53    29        FETCH_DIM_R                                      ~35     !2, 'supplemental'
         30        TYPE_CHECK                                  128          ~35
         31      > JMPZ                                                     ~36, ->50
   54    32    >   FETCH_DIM_R                                      ~37     !2, 'supplemental'
         33      > FE_RESET_R                                       $38     ~37, ->45
         34    > > FE_FETCH_R                                       ~39     $38, !11, ->45
         35    >   ASSIGN                                                   !12, ~39
   55    36        ROPE_INIT                                     7  ~42     '%3C'
         37        ROPE_ADD                                      1  ~42     ~42, !12
         38        ROPE_ADD                                      2  ~42     ~42, '%3E%3C%21%5BCDATA%5B'
         39        ROPE_ADD                                      3  ~42     ~42, !11
         40        ROPE_ADD                                      4  ~42     ~42, '%5D%5D%3E%3C%2F'
         41        ROPE_ADD                                      5  ~42     ~42, !12
         42        ROPE_END                                      6  ~41     ~42, '%3E'
         43        ASSIGN_OP                                     8          !10, ~41
   54    44      > JMP                                                      ->34
         45    >   FE_FREE                                                  $38
   57    46        ROPE_INIT                                     3  ~48     '%3Csupplemental%3E'
         47        ROPE_ADD                                      1  ~48     ~48, !10
         48        ROPE_END                                      2  ~47     ~48, '%3C%2Fsupplemental%3E'
         49        ASSIGN                                                   !10, ~47
   60    50    >   TYPE_CHECK                                    4          !6
         51      > JMPZ                                                     ~51, ->55
   61    52    >   FETCH_R                      global              ~52     '_POST'
         53        FETCH_DIM_R                                      ~53     ~52, 'action'
         54        ASSIGN                                                   !6, ~53
   63    55    >   ASSIGN                                                   !13, ''
   64    56        ROPE_INIT                                     5  ~57     '%3Cresponse+action%3D%27'
         57        ROPE_ADD                                      1  ~57     ~57, !6
         58        ROPE_ADD                                      2  ~57     ~57, '_'
         59        ROPE_ADD                                      3  ~57     ~57, !4
         60        ROPE_END                                      4  ~56     ~57, '%27%3E'
         61        ASSIGN_OP                                     8          !13, ~56
   65    62        ROPE_INIT                                     5  ~62     '%3C'
         63        ROPE_ADD                                      1  ~62     ~62, !5
         64        ROPE_ADD                                      2  ~62     ~62, '+id%3D%27'
         65        ROPE_ADD                                      3  ~62     ~62, !4
         66        ROPE_END                                      4  ~61     ~62, '%27+'
         67        TYPE_CHECK                                    4          !7
         68      > JMPZ                                                     ~65, ->71
         69    >   QM_ASSIGN                                        ~66     ''
         70      > JMP                                                      ->75
         71    >   ROPE_INIT                                     3  ~68     'old_id%3D%27'
         72        ROPE_ADD                                      1  ~68     ~68, !7
         73        ROPE_END                                      2  ~67     ~68, '%27+'
         74        QM_ASSIGN                                        ~66     ~67
         75    >   CONCAT                                           ~70     ~61, ~66
         76        ROPE_INIT                                     3  ~72     'position%3D%27'
         77        ROPE_ADD                                      1  ~72     ~72, !3
         78        ROPE_END                                      2  ~71     ~72, '%27%3E'
         79        CONCAT                                           ~74     ~70, ~71
         80        ASSIGN_OP                                     8          !13, ~74
   66    81        ASSIGN_OP                                     8          !13, !9
   67    82        ASSIGN_OP                                     8          !13, !10
   68    83        ROPE_INIT                                     3  ~79     '%3C%2F'
         84        ROPE_ADD                                      1  ~79     ~79, !5
         85        ROPE_END                                      2  ~78     ~79, '%3E'
         86        ASSIGN_OP                                     8          !13, ~78
   69    87        ASSIGN_OP                                     8          !13, '%3C%2Fresponse%3E'
   71    88        FETCH_OBJ_W                                      $83     'responses'
         89        ASSIGN_DIM                                               $83
         90        OP_DATA                                                  !13
   73    91      > RETURN                                                   !13
   74    92*     > RETURN                                                   null

End of function add

End of class WP_Ajax_Response.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.12 ms | 1462 KiB | 21 Q