3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User{ protected $activeProducts = null; protected $pdo; public function __construct(PDO $pdo = null){ $this->pdo = $pdo; } public function getProducts(){ if($this->activeProducts){ echo "getting from property (cache)\n"; return $this->activeProducts; } //$this->activeProducts = $this->pdo... a long task echo "getting from db\n"; $this->activeProducts = ['fake','products']; return $this->activeProducts; } } $user = new User(null);//for tests var_dump($user->getProducts()); var_dump($user->getProducts());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eXCha
function name:  (null)
number of ops:  15
compiled vars:  !0 = $user
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $1      'User'
          1        SEND_VAL_EX                                              null
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   23     4        INIT_FCALL                                               'var_dump'
          5        INIT_METHOD_CALL                                         !0, 'getProducts'
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   24     9        INIT_FCALL                                               'var_dump'
         10        INIT_METHOD_CALL                                         !0, 'getProducts'
         11        DO_FCALL                                      0  $6      
         12        SEND_VAR                                                 $6
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Class User:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eXCha
function name:  __construct
number of ops:  4
compiled vars:  !0 = $pdo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV_INIT                                        !0      null
    7     1        ASSIGN_OBJ                                               'pdo'
          2        OP_DATA                                                  !0
    8     3      > RETURN                                                   null

End of function __construct

Function getproducts:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eXCha
function name:  getProducts
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                      ~0      'activeProducts'
          1      > JMPZ                                                     ~0, ->5
   12     2    >   ECHO                                                     'getting+from+property+%28cache%29%0A'
   13     3        FETCH_OBJ_R                                      ~1      'activeProducts'
          4      > RETURN                                                   ~1
   16     5    >   ECHO                                                     'getting+from+db%0A'
   17     6        ASSIGN_OBJ                                               'activeProducts'
          7        OP_DATA                                                  <array>
   18     8        FETCH_OBJ_R                                      ~3      'activeProducts'
          9      > RETURN                                                   ~3
   19    10*     > RETURN                                                   null

End of function getproducts

End of class User.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.61 ms | 1396 KiB | 15 Q