3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Entity extends PDO { public function __construct() { try { parent::__construct('mysql:host=localhost;dbname=X', 'db_user', 'db_pass'); parent::setAttributes(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { die($e->getMessage()); }} } class DataSource { public static function simple_select($sql, array $values) { $smpt = (new Entity)->Prepare($sql); $smpt->execute($values); return $smpt->fetchAll(); } } class UniqueString { private $Secret; public function __construct($secret) { $this->Secret = $secret; } public function fetch() { return $this->Secret; } } class Generate { private static $Secret; private static $Sql = 'SELECT user_id FROM users WHERE salt = ?'; public static function randomString(int $len) { do { self::$Secret = mcrypt_create_iv($len, MCRYPT_DEV_URANDOM); } while (!empty(DataSource::simple_select(self::$Sql, [self::$Secret])['user_id'])); return new UniqueString(self::$Secret); } } echo Generate::randomString(16)->fetch();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jPCSd
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_STATIC_METHOD_CALL                                  'Generate', 'randomString'
          1        SEND_VAL                                                 16
          2        DO_FCALL                                      0  $0      
          3        INIT_METHOD_CALL                                         $0, 'fetch'
          4        DO_FCALL                                      0  $1      
          5        ECHO                                                     $1
          6      > RETURN                                                   1

Class Entity:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 10
Branch analysis from position: 10
2 jumps found. (Code = 107) Position 1 = 11, Position 2 = -2
Branch analysis from position: 11
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/jPCSd
function name:  __construct
number of ops:  15
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_STATIC_METHOD_CALL                                  
          1        SEND_VAL_EX                                              'mysql%3Ahost%3Dlocalhost%3Bdbname%3DX'
          2        SEND_VAL_EX                                              'db_user'
          3        SEND_VAL_EX                                              'db_pass'
          4        DO_FCALL                                      0          
    6     5        INIT_STATIC_METHOD_CALL                                  'setAttributes'
          6        SEND_VAL_EX                                              3
          7        SEND_VAL_EX                                              2
          8        DO_FCALL                                      0          
          9      > JMP                                                      ->14
    7    10  E > > CATCH                                       last         'PDOException'
         11    >   INIT_METHOD_CALL                                         !0, 'getMessage'
         12        DO_FCALL                                      0  $3      
         13      > EXIT                                                     $3
         14    > > RETURN                                                   null

End of function __construct

End of class Entity.

Class DataSource:
Function simple_select:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jPCSd
function name:  simple_select
number of ops:  15
compiled vars:  !0 = $sql, !1 = $values, !2 = $smpt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        NEW                                              $3      'Entity'
          3        DO_FCALL                                      0          
          4        INIT_METHOD_CALL                                         $3, 'Prepare'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !2, $5
   13     8        INIT_METHOD_CALL                                         !2, 'execute'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
   14    11        INIT_METHOD_CALL                                         !2, 'fetchAll'
         12        DO_FCALL                                      0  $8      
         13      > RETURN                                                   $8
   15    14*     > RETURN                                                   null

End of function simple_select

End of class DataSource.

Class UniqueString:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jPCSd
function name:  __construct
number of ops:  4
compiled vars:  !0 = $secret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        ASSIGN_OBJ                                               'Secret'
          2        OP_DATA                                                  !0
   23     3      > RETURN                                                   null

End of function __construct

Function fetch:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jPCSd
function name:  fetch
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   FETCH_OBJ_R                                      ~0      'Secret'
          1      > RETURN                                                   ~0
   27     2*     > RETURN                                                   null

End of function fetch

End of class UniqueString.

Class Generate:
Function randomstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 1
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 1
filename:       /in/jPCSd
function name:  randomString
number of ops:  25
compiled vars:  !0 = $len
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   35     1    >   INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
          2        SEND_VAR_EX                                              !0
          3        FETCH_CONSTANT                                   ~2      'MCRYPT_DEV_URANDOM'
          4        SEND_VAL_EX                                              ~2
          5        DO_FCALL                                      0  $3      
          6        ASSIGN_STATIC_PROP                                       'Secret'
          7        OP_DATA                                                  $3
   36     8        INIT_STATIC_METHOD_CALL                                  'DataSource', 'simple_select'
          9        FETCH_STATIC_PROP_R          unknown             ~4      'Sql'
         10        SEND_VAL                                                 ~4
         11        FETCH_STATIC_PROP_R          unknown             ~5      'Secret'
         12        INIT_ARRAY                                       ~6      ~5
         13        SEND_VAL                                                 ~6
         14        DO_FCALL                                      0  $7      
         15        ISSET_ISEMPTY_DIM_OBJ                         1  ~8      $7, 'user_id'
         16        BOOL_NOT                                         ~9      ~8
         17      > JMPNZ                                                    ~9, ->1
   37    18    >   NEW                                              $10     'UniqueString'
         19        CHECK_FUNC_ARG                                           
         20        FETCH_STATIC_PROP_FUNC_ARG   unknown             $11     'Secret'
         21        SEND_FUNC_ARG                                            $11
         22        DO_FCALL                                      0          
         23      > RETURN                                                   $10
   38    24*     > RETURN                                                   null

End of function randomstring

End of class Generate.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.35 ms | 1403 KiB | 13 Q