3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Cookie implements ArrayAccess { public function offsetSet($offset, $value) { setcookie($offset, $value); } public function offsetGet($offset) { return $_COOKIE[$offset]; } public function offsetUnset($offset) { setcookie($offset, null, time()-1); } public function offsetExists($offset) { return isset($_COOKIE[$offset]); } } $cookie = new Cookie; // 读取Cookie print $cookie["username"]; // 写入Cookie $cookie["passwd"] = "123abc";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XHZIl
function name:  (null)
number of ops:  9
compiled vars:  !0 = $cookie
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'cookie'
   20     1        NEW                                              $1      'Cookie'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   22     4        FETCH_DIM_R                                      ~4      !0, 'username'
          5        ECHO                                                     ~4
   24     6        ASSIGN_DIM                                               !0, 'passwd'
          7        OP_DATA                                                  '123abc'
          8      > RETURN                                                   1

Class Cookie:
Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XHZIl
function name:  offsetSet
number of ops:  7
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'setcookie'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                                 
    5     6      > RETURN                                                   null

End of function offsetset

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XHZIl
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        FETCH_R                      global              ~1      '_COOKIE'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
    9     4*     > RETURN                                                   null

End of function offsetget

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XHZIl
function name:  offsetUnset
number of ops:  10
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'setcookie'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 null
          4        INIT_FCALL                                               'time'
          5        DO_ICALL                                         $1      
          6        SUB                                              ~2      $1, 1
          7        SEND_VAL                                                 ~2
          8        DO_ICALL                                                 
   13     9      > RETURN                                                   null

End of function offsetunset

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XHZIl
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        FETCH_IS                                         ~1      '_COOKIE'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3      > RETURN                                                   ~2
   18     4*     > RETURN                                                   null

End of function offsetexists

End of class Cookie.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.2 ms | 1400 KiB | 17 Q