3v4l.org

run code in 300+ PHP versions simultaneously
<?php class JavaScriptObject { protected $varName; protected $object; protected $jh; public function __constuct() { $this->jh = Loader::helper('json'); } public function setVarName($varName) { $this->varName = $this->jh->encode($varName); } public function addObject($arg) { $this->object = $this->jh->encode($object); } public function __toString() { return 'var ' . $this->varName . ' = ' . $this->object . ';'; } } $jo = new JavaScriptObject(); $jo->setVarName('v'); $options = new stdObject; $options->size = 10; $options->enabled = false; $jo->addObject($options); echo $jo;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lNjpG
function name:  (null)
number of ops:  19
compiled vars:  !0 = $jo, !1 = $options
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'javascriptobject'
   26     1        NEW                                              $2      'JavaScriptObject'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   27     4        INIT_METHOD_CALL                                         !0, 'setVarName'
          5        SEND_VAL_EX                                              'v'
          6        DO_FCALL                                      0          
   28     7        NEW                                              $6      'stdObject'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !1, $6
   29    10        ASSIGN_OBJ                                               !1, 'size'
         11        OP_DATA                                                  10
   30    12        ASSIGN_OBJ                                               !1, 'enabled'
         13        OP_DATA                                                  <false>
   31    14        INIT_METHOD_CALL                                         !0, 'addObject'
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0          
   33    17        ECHO                                                     !0
         18      > RETURN                                                   1

Class JavaScriptObject:
Function __constuct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lNjpG
function name:  __constuct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_STATIC_METHOD_CALL                                  'Loader', 'helper'
          1        SEND_VAL_EX                                              'json'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN_OBJ                                               'jh'
          4        OP_DATA                                                  $1
   10     5      > RETURN                                                   null

End of function __constuct

Function setvarname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lNjpG
function name:  setVarName
number of ops:  8
compiled vars:  !0 = $varName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        FETCH_OBJ_R                                      ~2      'jh'
          2        INIT_METHOD_CALL                                         ~2, 'encode'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $3      
          5        ASSIGN_OBJ                                               'varName'
          6        OP_DATA                                                  $3
   14     7      > RETURN                                                   null

End of function setvarname

Function addobject:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lNjpG
function name:  addObject
number of ops:  8
compiled vars:  !0 = $arg, !1 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        FETCH_OBJ_R                                      ~3      'jh'
          2        INIT_METHOD_CALL                                         ~3, 'encode'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0  $4      
          5        ASSIGN_OBJ                                               'object'
          6        OP_DATA                                                  $4
   18     7      > RETURN                                                   null

End of function addobject

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lNjpG
function name:  __toString
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   FETCH_OBJ_R                                      ~0      'varName'
          1        CONCAT                                           ~1      'var+', ~0
          2        CONCAT                                           ~2      ~1, '+%3D+'
          3        FETCH_OBJ_R                                      ~3      'object'
          4        CONCAT                                           ~4      ~2, ~3
          5        CONCAT                                           ~5      ~4, '%3B'
          6        VERIFY_RETURN_TYPE                                       ~5
          7      > RETURN                                                   ~5
   22     8*       VERIFY_RETURN_TYPE                                       
          9*     > RETURN                                                   null

End of function __tostring

End of class JavaScriptObject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.01 ms | 1390 KiB | 13 Q