3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Person { public $name; public $age; public $role; } class Role { public $name; } $person = new Person(); $person->name = 'Name'; $person->age = 20; $person->role = new Role(); $jsonObj = json_encode($person, 0, 1); var_dump($jsonObj); $errors = array( JSON_ERROR_NONE => "JSON_ERROR_NONE", JSON_ERROR_DEPTH => "JSON_ERROR_DEPTH", JSON_ERROR_STATE_MISMATCH => "JSON_ERROR_STATE_MISMATCH", JSON_ERROR_CTRL_CHAR => "JSON_ERROR_CTRL_CHAR", JSON_ERROR_SYNTAX => "JSON_ERROR_SYNTAX", JSON_ERROR_UTF8 => "JSON_ERROR_UTF8", JSON_ERROR_RECURSION => "JSON_ERROR_RECURSION", JSON_ERROR_INF_OR_NAN => "JSON_ERROR_INF_OR_NAN", JSON_ERROR_UNSUPPORTED_TYPE => "JSON_ERROR_UNSUPPORTED_TYPE" ); var_dump($errors[json_last_error()]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AHvH6
function name:  (null)
number of ops:  28
compiled vars:  !0 = $person, !1 = $jsonObj, !2 = $errors
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   NEW                                                  $3      'Person'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $3
   16     3        ASSIGN_OBJ                                                   !0, 'name'
          4        OP_DATA                                                      'Name'
   17     5        ASSIGN_OBJ                                                   !0, 'age'
          6        OP_DATA                                                      20
   18     7        NEW                                                  $9      'Role'
          8        DO_FCALL                                          0          
          9        ASSIGN_OBJ                                                   !0, 'role'
         10        OP_DATA                                                      $9
   19    11        INIT_FCALL                                                   'json_encode'
         12        SEND_VAR                                                     !0
         13        SEND_VAL                                                     0
         14        SEND_VAL                                                     1
         15        DO_ICALL                                             $11     
         16        ASSIGN                                                       !1, $11
   21    17        INIT_FCALL                                                   'var_dump'
         18        SEND_VAR                                                     !1
         19        DO_ICALL                                                     
   23    20        ASSIGN                                                       !2, <array>
   34    21        INIT_FCALL                                                   'var_dump'
         22        INIT_FCALL                                                   'json_last_error'
         23        DO_ICALL                                             $15     
         24        FETCH_DIM_R                                          ~16     !2, $15
         25        SEND_VAL                                                     ~16
         26        DO_ICALL                                                     
         27      > RETURN                                                       1

Class Person: [no user functions]
Class Role: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
126.89 ms | 480 KiB | 10 Q