3v4l.org

run code in 300+ PHP versions simultaneously
<?php function e($o){return json_decode(preg_replace('/\\\u0000[*a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\\u0000/','',json_encode((array)$o)),1);} class Foo { public function test() { echo 'test'; } } function changeMe(&$obj) { $obj = function(){ }; //$reflectionClass = new ReflectionClass($obj); //var_dump($reflectionClass); $arr = (array) $obj; $out = json_encode($arr); $out = preg_replace('/\\\u0000[*a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\\u0000/', '', $out); echo $out . PHP_EOL; $newArray = json_decode($out, true); var_dump($arr, $newArray); } $foo = new Foo(); changeMe($foo); $foo->test();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/beA6N
function name:  (null)
number of ops:  9
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   32     3        INIT_FCALL                                               'changeme'
          4        SEND_REF                                                 !0
          5        DO_FCALL                                      0          
   34     6        INIT_METHOD_CALL                                         !0, 'test'
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

Function e:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/beA6N
function name:  e
number of ops:  16
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'json_decode'
          2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAL                                                 '%2F%5C%5Cu0000%5B%2Aa-zA-Z_%5Cx7f-%5Cxff%5D%5Ba-zA-Z0-9_%5Cx7f-%5Cxff%5D%2A%5C%5Cu0000%2F'
          4        SEND_VAL                                                 ''
          5        INIT_FCALL                                               'json_encode'
          6        CAST                                          7  ~1      !0
          7        SEND_VAL                                                 ~1
          8        DO_ICALL                                         $2      
          9        SEND_VAR                                                 $2
         10        DO_ICALL                                         $3      
         11        SEND_VAR                                                 $3
         12        SEND_VAL                                                 1
         13        DO_ICALL                                         $4      
         14      > RETURN                                                   $4
         15*     > RETURN                                                   null

End of function e

Function changeme:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/beA6N
function name:  changeMe
number of ops:  27
compiled vars:  !0 = $obj, !1 = $arr, !2 = $out, !3 = $newArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FbeA6N%3A15%240'
          2        ASSIGN                                                   !0, ~4
   19     3        CAST                                          7  ~6      !0
          4        ASSIGN                                                   !1, ~6
   21     5        INIT_FCALL                                               'json_encode'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !2, $8
   22     9        INIT_FCALL                                               'preg_replace'
         10        SEND_VAL                                                 '%2F%5C%5Cu0000%5B%2Aa-zA-Z_%5Cx7f-%5Cxff%5D%5Ba-zA-Z0-9_%5Cx7f-%5Cxff%5D%2A%5C%5Cu0000%2F'
         11        SEND_VAL                                                 ''
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !2, $10
   23    15        CONCAT                                           ~12     !2, '%0A'
         16        ECHO                                                     ~12
   24    17        INIT_FCALL                                               'json_decode'
         18        SEND_VAR                                                 !2
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $13     
         21        ASSIGN                                                   !3, $13
   25    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !1
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                                 
   28    26      > RETURN                                                   null

End of function changeme

Function %00%7Bclosure%7D%2Fin%2FbeA6N%3A15%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/beA6N
function name:  {closure}
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FbeA6N%3A15%240

Class Foo:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/beA6N
function name:  test
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ECHO                                                     'test'
   10     1      > RETURN                                                   null

End of function test

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.93 ms | 1402 KiB | 22 Q